标题:[求助]C++中关于类方法的简单调用错误
取消只看楼主
wz_wxz
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-3
 问题点数:0 回复次数:2 
[求助]C++中关于类方法的简单调用错误

jH3hUs9L.txt (687 Bytes) [求助]C++中关于类方法的简单调用错误

程序如下:(可以见附件) #include<iostream.h> class employee { public: int getage() const; void setage(int age); int getyearsofservice()const; void setyearsofservice(int years); int getsalary() const; void setsalary(int salary); private: int age; int yearsofservice; int salary; }; int main() { employee john; employee sally; john.setage(30); john.setyearsofservice(5); john.setsalary(50000); sally.setage(32); sally.setyearsofservice(8); sally.setsalary(40000); cout<<"john is"<<john.getage<<"years old and he has been with"; cout<<"the firm for"<<john.getyearsofservice<<"year .\n"; cout<<"john earns $"<<john.getsalary()<<"dollars per year. \n\n"; return 0; } 为什么编译时报这种错误: Compiling... 61.cpp C:\myvc\61\61.cpp(26) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion) C:\myvc\61\61.cpp(27) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion) Error executing cl.exe.

61.exe - 2 error(s), 0 warning(s)

搜索更多相关主题的帖子: int sally employee john 
2005-06-03 23:23
wz_wxz
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-3
得分:0 
为什么没人回答呢?先顶下!
2005-06-04 18:00
wz_wxz
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-3
得分:0 
谢谢你的帮助和建议。我忘记加类的实现部分了。
2005-06-05 21:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-20041-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021553 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved