名为Universes的类使用States类型的数据成员,而States使用Universes类型的对象。我正在使用 Visual C++ 2010 Express(如果这有什么不同的话)。
状态.h:
class Universes;
extern Universes universe;
class States
{
public:
int relations;
States();
};
States::States()
{
relations = universe.state_no;
}
宇宙.h
#include "States.h"
class Universes
{
public:
States state;
int state_no;
};
测试.cpp
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include "Universes.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Universes universe;
_getch();
return 0;
}
我不断收到以下错误:
States.h(16): error C2027: use of undefined type 'Universes'
States.h(1) : see declaration of 'Universes'
States.h(16): error C2228: left of '.state_no' must have class/struct/union