错误:表达式必须具有类类型 我在C++中有一个问题。是这样写的
在第二个来源中错误:表达式必须具有类类型 我在C++中有一个问题。是这样写的,c++,C++,在第二个来源中 void idealtype::compare(idealtype T1) { if (height.size() > T1.height.size()) cout << T1.getname() << " " << T1.getage() << "\t" << T1.getheight() << "\n"; else if (height.size() < T1.height.size(
void idealtype::compare(idealtype T1)
{
if (height.size() > T1.height.size())
cout << T1.getname() << " " << T1.getage() << "\t" << T1.getheight() << "\n";
else if (height.size() < T1.height.size())
cout << getname() << " " << getage() << "\t" << getheight() << "\n";
else if (height.size() == T1.height.size())
{
cout << T1.getname() << " " << T1.getage() << "\t" << T1.getheight() << "\n";
cout << getname() << " " << getage() << "\t" << getheight() << "\n";
}
cout << "\n";
}
主要来源;
我认为一切都做得很好,但视觉一直在向我展示
(在第二个源代码中,在每个if()状态上)错误:表达式必须具有类类型
那么,这个问题的关键是什么
请帮帮我,伙计们:)
那么,这个问题的关键是什么
在你的代码里你说
if (height.size() > T1.height.size())
class idealtype {
// ...
private:
int height; // <<<<<<<<<<<<
};
if(height.size()>T1.height.size())
类idealtype{
// ...
私人:
int height;//检查height.size()
你的意思是sizeof(height)
?我没有得到你想要的,height
被声明为int
成员。idealtype A(A,b,c)
:你缺少一个;
。
private:
int height;
}
idealtype A(a,b,c) // c is "height"
idealtype B(a,b,c) // c is "height"
B.compare(A)
if (height.size() > T1.height.size())
class idealtype {
// ...
private:
int height; // <<<<<<<<<<<<
};