【发布时间】:2013-10-10 08:48:39
【问题描述】:
我希望我的 caba 结构包含一个指向 aba 结构变量的指针。而且我还希望 aba 结构根据 set 的属性进行一些操作。
但是当我在 caba 中使用 aba 指针的属性时,我得到一个错误
#include<stdio.h>
#include<set>
using namespace std;
struct aba;
struct caba
{
aba *m;
int z;
bool operator >(const caba &other)
{
if(m==NULL||other.m==NULL)
return true;
return (*m).x>(*(other.m)).x;
}
};
set <caba> t;
struct aba
{
int x,y;
bool f()
{
return !t.empty();
}
};
int main()
{
return 0;
}
说:
在成员函数`bool caba::operator>(const caba&)'中:
Test.cpp|13|错误:无效使用未定义类型`struct aba'
Test.cpp|4|错误:`struct aba' 的前向声明
Test.cpp|13|错误:无效使用未定义类型`struct aba'
Test.cpp|4|错误:`struct aba' 的前向声明
但为什么 aba 未定义?它有一个原型。
【问题讨论】: