My App doesnt reply anthing after input

#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
How do I initialize the pointer


1
2
3
4
minion* pMinion = new minion();
if (hola == pMinion->monsterPosition)
...
delete pMinion;


or:

1
2
3
4
 minion m;
if (hola == m.monsterPosition)
...


If you use new you need to use delete
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.
Thank you so much Peter
@ajh32 The code minion* pMinion, when I run it the compiler shows undefined reference to minion::minion.

The code minion* pMinion, when I run it the compiler shows undefined reference to minion::minion


Show all your code, and indicate which files it's in
Show all your code, and indicate which files it's in

And please use code tags when doing so, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.