请问在VC6MFC一新类中为什么不能定义友元函数?
class khgl
{
public:
khgl(int id1,CString text,CString name1,bool secret1,int type1);
khgl();
virtual ~khgl();friend void dusj(int id2,CString text1,CString name2,bool secret2,int type2);//这里的友元函数不被承认为什么?
private:
int type;//发送的信息的标识是进行什么样的处理
CString name;//用户名
int id;//标识头像的ID
CString strtext;//用于存放客户向服务器发送的信息
bool secret;//用于标识是否为悄悄话
public:
};
class khgl
{
public:
khgl(int id1,CString text,CString name1,bool secret1,int type1);
khgl();
virtual ~khgl();friend void dusj(int id2,CString text1,CString name2,bool secret2,int type2);//这里的友元函数不被承认为什么?
private:
int type;//发送的信息的标识是进行什么样的处理
CString name;//用户名
int id;//标识头像的ID
CString strtext;//用于存放客户向服务器发送的信息
bool secret;//用于标识是否为悄悄话
public:
};
khgl void dusj(int id2,CString text1,CString name2,bool secret2,int type2,khgl* p);我在按以上的改了一下编译器报的错误在下面说明:
Compiling...
gcDlg.cpp
e:\网络编程\第三章\chat\gc\khgl.h(18) : error C2628: 'khgl' followed by 'void' is illegal (did you forget a ';'?)
khgl.cpp
e:\网络编程\第三章\chat\gc\khgl.h(18) : error C2628: 'khgl' followed by 'void' is illegal (did you forget a ';'?)
E:\网络编程\第三章\chat\gc\khgl.cpp(39) : error C2039: 'dusj' : is not a member of 'khgl'
e:\网络编程\第三章\chat\gc\khgl.h(13) : see declaration of 'khgl'
E:\网络编程\第三章\chat\gc\khgl.cpp(40) : error C2556: 'void __cdecl dusj(int,class CString,class CString,bool,int,class khgl *)' : overloaded function differs only by return type from 'class khgl __cdecl dusj(int,class CString,class CString,bool,in
t,class khgl *)'
e:\网络编程\第三章\chat\gc\khgl.h(18) : see declaration of 'dusj'
E:\网络编程\第三章\chat\gc\khgl.cpp(40) : error C2371: 'dusj' : redefinition; different basic types
e:\网络编程\第三章\chat\gc\khgl.h(18) : see declaration of 'dusj'
Generating Code...
Compiling...
gc.cpp
e:\网络编程\第三章\chat\gc\khgl.h(18) : error C2628: 'khgl' followed by 'void' is illegal (did you forget a ';'?)
Generating Code...
Error executing cl.exe.gc.exe - 6 error(s), 0 warning(s)
我在 .CPP