Q:

How do I call a method from another class in C++

I need help, I want to call generateNumber from a class called MagicNumber in another class called GuessMachine.
MagicNumber class,
    int MagicNumber::generateNumber()
    {
        int dice = 1;   
        srand(time(0));
        dice = (rand() % 6 ) + 1;
        return dice;
    }

I want to call the above method in the class below, GuessMachine class.
    void GuessMachine::checkNumber(MagicNumber& mN, int a)
    {
        int guessNumber=0;
        int tries=0;

        while(nTimes>=tries)
        {
            cout<<"Please enter a number between 1 to 6: ";
            cin>>guessNumber;

            a.generateNumber(); //<-- This is where it went wrong

            tries++;
        }
    }

Please help.

A:

Of course, it should be
mN.generateNumber();

a is an int.

