#include <stdlib.h>
#include <iostream>
using namespace std;
#include "stdafx.h"
class MyClass;
class A
{
public:
A()
{
m_ia = 0;
printf("A()\n");
}
A& operator=(const A &a)
{
printf("=\n");
return *this;
}
friend void display1(MyClass);
friend class MyClass;
private:
int m_ia;
};
class MyClass
{
void output();
private:
};
void MyClass::output()
{
A a;
a.m_ia = 10;
}
class B
{
friend void display1(MyClass);
};
void display1(MyClass a)
{
//printf("\n%d\n",a.m_ia);
cout <<"ddd" << endl;
}
int main(void)
{
//A a;
MyClass b;
//a = b;
display1(b);
display1(b);
getchar();
return 0;
}
友元函数的代码
最新推荐文章于 2022-10-29 21:52:24 发布