友元类
来源:互联网 发布:ds file windows 编辑:程序博客网 时间:2024/06/08 02:49
/////////////////////////////////
#include <iostream>
using namespace std;
class Area;
class Point
{
private:
friend class Area;
void show();
};
class Area
{
public:
void display();
private:
int x,y,z;
};
void Point::show()
{
cout<<"Point!"<<endl;
}
void Area::display()
{
Point p;
p.show();
}
int main()
{
Area a;
a.display();
return 0;
}
#include <iostream>
using namespace std;
class Area;
class Point
{
private:
friend class Area;
void show();
};
class Area
{
public:
void display();
private:
int x,y,z;
};
void Point::show()
{
cout<<"Point!"<<endl;
}
void Area::display()
{
Point p;
p.show();
}
int main()
{
Area a;
a.display();
return 0;
}