a.h:
----------------------------------------
#ifndef __A_H
#define __A_H
class CB;
class CA
{
public:
CA(){n = 2;}
~CA(){}
void show(CB aCb);
void show(void);
public:
int n;
};
#endif
-------------------------------------------
a.cpp
-------------------------------------------
#include <iostream>
#include "a.h"
#include "b.h"
using namespace std;
void CA::show(CB aCb)
{
cout<<aCb.n<<endl;
}
void CA::show(void)
{
cout<<n<<endl;
}
-------------------------------------------
b.h
-------------------------------------------
#ifndef __B_H
#define __B_H
#include "a.h"
class CB
{
public:
CB(){ n = 3;}
~CB(){}
void show(CA aCa);
public:
int n;
class CA m_Ca;
};
#endif
-------------------------------------------
b.cpp
-------------------------------------------
#include <iostream>
#include "b.h"
using namespace std;
void CB::show(CA aCa)
{
cout<<aCa.n<<endl;
}
-------------------------------------------
不必多说,其中的道理个人去领悟吧!