私を夢中にさせた回覧インクルードについて質問があります。
main.cpp
#include "A.hpp"
#include "B.hpp"
int main()
{
A a();
B b();
return 0;
}
A.hpp
#ifndef _CLASS_A
#define _CLASS_A
#include "B.hpp"
class A
{
public:
B* b;
struct A_t
{
int id;
};
};
#endif
B.hpp
#ifndef _CLASS_B
#define _CLASS_B
#include "A.hpp"
class B
{
class A; //Ok, with that I can use the class A
public:
int a;
A* b; // That work!
A::A_t *aStruct; // Opss! that throw a compilation error.
};
#endif
問題は: ¿クラス B で A_t 構造体を使用するにはどうすればよいですか?
次のような前方宣言を追加しようとしました。
struct A::A_t;
しかし、それは明らかに機能します。