有什么方法可以让 class 成为 typedef 的朋友吗?
Is there any way to make a typedef friend of a class?
...以我为例:
template<class X>
struct _Command {
char* id;
char* description;
char messages[10][100];
bool (X::*function)();
};
Class Server {
public:
typedef _Command<Server>Command;
}
如何让 Command 成为服务器 class 的好友?
友元声明中可以正常使用typedef:
class Server {
public:
typedef _Command<Server> Command;
friend Command;
};
...以我为例:
template<class X>
struct _Command {
char* id;
char* description;
char messages[10][100];
bool (X::*function)();
};
Class Server {
public:
typedef _Command<Server>Command;
}
如何让 Command 成为服务器 class 的好友?
友元声明中可以正常使用typedef:
class Server {
public:
typedef _Command<Server> Command;
friend Command;
};