I have written a class inside a file called MyClass.h and it's member functions are located inside a file called MyClass.cpp.
How would I (if possible) access the objects created inside that .cpp file from outside that file?
MyClass.cpp
MyClass* player[] = { nullptr, nullptr}; //The player objects are created using a for loop.
for (i = 0; i < MyClass::createPlayers; ++i)
player[i] = new MyClass;
main.cpp
player[i]->getName(); //error: "identifier is undefined"`
MyClass.h
class MyClass
{
public:
MyClass(); //constructor
~MyClass(); //destructor
string getName() { return name; }; //returns the name
private:
string name; //the players' name
};