#include <iostream>
using namespace std;
class minion
{
minion();
~minion();
public:
int monsterPosition = 50;
int monsterMovement;
void monster();
private:
string monsterLocation;
string monsterName;
string monsterWorld;
};
void monster(int hola)
{
minion *minion;
if (hola==minion->monsterPosition)
cout << "You have been wrecked" << endl;
else
cout << "Good game bro" << endl;
}
int main()
{
int read;
cout << "Enter the monster position" << endl;
cin >> read;
monster(read);
}
When I enter the monster position . The app shows nothing
You have not initialized the minion pointer so if (hola==minion->monsterPosition)
will not work.
I'm at intermediate level in c++. How do I initialize the pointer
To be able to create and delete minion objects from outside the class as shown by ajh32 you also need to make the constructor and destructor public.
@ajh32 The code minion* pMinion, when I run it the compiler shows undefined reference to minion::minion.