I have this simple code where two inner classes are depending on each other. I can't call object's functionB()
inside of functionC()
although as you can see I have created a pointer to an object of ClassB
and even instantiated the object yet I still get the error that I need to call the function from an object. I was wondering what exactly am I doing wrong here?
#include <iostream>
class ClassA
{
public:
ClassA() { object = new ClassB(); };
~ClassA();
void functionA() { };
private:
class ClassB
{
public:
void functionB() { std::cout << "Function B"; };
};
class ClassC
{
public:
void functionC() {
std::cout << "Fuction C";
object->functionB();
}; //Error here
};
ClassB* object;
ClassC* object1;
};