我只是有一个什么一段代码在这个简单的例子是干什么的问题。我查了好友类并了解它们是如何工作的,但我不明白顶层的类声明实际上在做什么(即机器人)。这是否意味着Happy类可以使用Robot对象,但他们无法访问其私有部分,任何信息将不胜感激。
#include <stdlib.h>
#include <stdexcept>
template <typename T> // What is this called when included
class Robot; // is there a special name for defining a class in this way
template <typename T>
class Happy
{
friend class Joe<T>;
friend class Robot<Happy<T> >;
// ...
};
http://stackoverflow.com/questions/4926105/what-is-forward-declaration-in-c – mydogisbox 2012-04-13 21:36:36