谁帮我看看这个类为什么通不过?

来源:百度知道 编辑:UC知道 时间:2024/05/15 11:38:41
class Cqueue
{
public:
Cqueue(){c = 8;}
int GetLength(){return c;}
protected:
int c;
};

void main()
{
Cqueue point();
int a = point.GetLength();
}

编译就说
error C2228: left of '.GetLength' must have class/struct/union type

class Cqueue
{
public:
Cqueue(){c = 8;}
int GetLength(){return c;}
protected:
int c;
};

void main()
{
Cqueue point(); //把这一行改成:Cqueue point;就行了啦
int a = point.GetLength();
}

构造函数的问题啦
你或者初始化的时候带上
不初始化的话不要加括号

楼上正解,构造函数是你在创建该类型的变量时系统自己引用的(除非你的构造函数带有参数),不用象函数一样加个括号

同意 心随灵动あ的说法

这是什么啊

看不懂

真是的