К примеру два класса:
//Class1.h
#ifndef CLASS1_H_INCLUDED
#define CLASS1_H_INCLUDED
#include "Class2.h"
class Class1
{
public:
Class1();
~Class1();
private:
Class2 * cl2;
};
#endif // CLASS1_H_INCLUDED
//Class2.h
#ifndef CLASS2_H_INCLUDED
#define CLASS2_H_INCLUDED
#include "Class1.h"
class Class2
{
public:
Class2();
~Class2();
private:
Class1 * cl1;
};
#endif // CLASS2_H_INCLUDED
//Class1.cpp
#include "class1.h"
Class1::Class1() { cl2 = new Class2();}
Class1::~Class1(){ delete cl2; cl2 = 0;}
//Class2.cpp
#include "class2.h"
Class2::Class2() { cl1 = new Class1();}
Class2::~Class2(){ delete cl1; cl1 = 0;}