-- 作者:伟伟联盟
-- 发布时间:4/8/2008 8:41:00 PM
-- 大虾[求助]
[B][size=4][这是我的考试题目,当我调试运行时总是显示某处错误,最后面是错误说明,请大侠指点。 #include <iostream.h> #include <string.h> class CStudent { private: char name[30]; int code; double score; public: CStudent(char* nm) { strcpy(name,nm); } CStudent(){} void putname(char* nm){ strcpy(name, nm);} void putcode(int d){ code=d;} void putscore(double sc){ score=sc;} void getname(char* nm){ strcpy(nm, name);} double getcode(){ return code;} double getscore(){ return score;} void addscore(double sc) { score+=sc; } }; class CGraduateStudent: public CStudent { private: char advisor[30]; int paper; public: void putadvisor(char* nm){ strcpy(advisor, nm);} void getadvisor(char* nm){ strcpy(nm, advisor);} void putpaper(int d){ paper=d;} void addpaper (int d){paper+=d;} int getpaper(){ return paper;} }; void main() { CGraduateStudent sdt; sdt.putname("Hanson"); sdt.putadvisor("MichaelPhong"); sdt.putpaper(8); std.addpaper(2); char csname[30]; sdt.getname(csname); char caname[30]; sdt.getadvisor(caname); cout<<"Student "<<csname<<endl; cout<<"(Advisor: "<<caname<<")"<<endl; cout << "Total paper is " << sdt.getpaper() <<endl; } 运行后提示: 正在编译... stdafx.cpp 正在编译... 7.cpp c:\documents and settings\administrator\my documents\visual studio 2005\projects\7\7\7.cpp(23) : warning C4996: “strcpy”被声明为否决的 e:\c++\vc\include\string.h(73) : 参见“strcpy”的声明 消息:“This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.” c:\documents and settings\administrator\my documents\visual studio 2005\projects\7\7\7.cpp(26) : warning C4996: “strcpy”被声明为否决的 e:\c++\vc\include\string.h(73) : 参见“strcpy”的声明 消息:“This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.” c:\documents and settings\administrator\my documents\visual studio 2005\projects\7\7\7.cpp(29) : warning C4996: “strcpy”被声明为否决的 e:\c++\vc\include\string.h(73) : 参见“strcpy”的声明 消息:“This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.” c:\documents and settings\administrator\my documents\visual studio 2005\projects\7\7\7.cpp(43) : warning C4996: “strcpy”被声明为否决的 e:\c++\vc\include\string.h(73) : 参见“strcpy”的声明 消息:“This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.” c:\documents and settings\administrator\my documents\visual studio 2005\projects\7\7\7.cpp(44) : warning C4996: “strcpy”被声明为否决的 e:\c++\vc\include\string.h(73) : 参见“strcpy”的声明 消息:“This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.” c:\documents and settings\administrator\my documents\visual studio 2005\projects\7\7\7.cpp(55) : error C2882: “std”: 在表达式中非法使用命名空间标识符 c:\documents and settings\administrator\my documents\visual studio 2005\projects\7\7\7.cpp(55) : error C2228: “.addpaper”的左边必须有类/结构/联合 生成日志保存在“file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\7\7\Debug\BuildLog.htm” 7 - 2 个错误,5 个警告 ========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========[/size][/size][/size][/size][/size][/size][/size][/B]
|