class Teacher{private: int ID; string qualification; double salary; Date dob; Date dateJoined;public: Teacher(); voID setTeacher (int,string,double); string getQualification(); voID displayTeacher();}//This is my constructorTeacher::Teacher(){ ID = 0; qualification =" " ; salary=0.0;}
我收到错误C2533:’Teacher :: {ctor}’:构造函数不允许返回类型.
我哪里做错了?
这会让解析器感到困惑,现在认为你正在写这样的东西:
class {} functionname(args) {} ^^^^^^^^ ^^^^^^^^^^^^return type constructors defined are functions,but in-place they don't have (oops) return types! (oops)
现代GCC(比如4.9.2)对这个问题非常清楚:
class Teacher{ Teacher();}Teacher::Teacher(){}// main.cpp:3:1: error: new types may not be defined in a return type// class Teacher// ^// main.cpp:3:1: note: (perhaps a semicolon is missing after the deFinition of 'Teacher')// main.cpp:8:18: error: return type specification for constructor invalID// Teacher::Teacher()// ^
(live demo)
总结以上是内存溢出为你收集整理的C错误C2533,ctor:构造函数不允许返回类型全部内容,希望文章能够帮你解决C错误C2533,ctor:构造函数不允许返回类型所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)