重複の可能性:
C++ の前方宣言とは何ですか?
この単純な例でコードが何をしているのかについて質問があります。フレンド クラスを調べて、それらがどのように機能するかを理解しましたが、一番上のクラス宣言 (つまり、ロボット) が実際に何をしているのか理解できません。これは、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> >;
// ...
};