I need to build a set of classes that are dependent on each other. I am having trouble when I pass a pointer to one class to another class that is instantiated inside it.
Here an example to illustrate my problem.
#include<iostream>
#include<vector>
using namespace std;
class base;
//
 child class
    class child
    {
    public:
    child(){};
    void setPointer (base* ptr){pointer = ptr; }
    void printing(){(*pointer).print();} // error C2027: use of undefubed type base
                                        // error C2227: '.print' must have class/struct/union
private:
    base* pointer;
};
// base class
class base
{
public:
    base()
    {
        initial_vec();
        VEC[0].setPointer(this);
        VEC[0].printing();
    }
    void print() { cout <<"printing from BASE"<< endl;}
    void initial_vec ()
    {
        child child1;
        VEC.push_back(child1);
    }
private:
    vector<child> VEC;
};
int main()
{
    base b1;
    system("pause");
    return 1;
}
Do you have any idea how I achieve that without getting those errors ?
Thank you in advance
 
     
     
    