东南大学机试-A卷-答案.docVIP

  • 9
  • 0
  • 约3.04千字
  • 约 5页
  • 2018-07-01 发布于河南
  • 举报
东南大学机试-A卷-答案

东南大学09级C++(下)上机试卷A-答案 一、改错题(50分)本题共10个错误,每个错误5分 #include iostream #include cstring using namespace std; class student { char *pName; public: student(); student(char *pname); student(student s); ~student(); student operator=(student s); void print(); }; student::student() { coutConstructor; pName=NULL; cout缺省endl; } student::student ( char *pname ) { coutConstructor; int len = strlen(pname); pName = new char[len+1]; //改为len+1 if ( pName ) strcpy ( pName, pname); //pName和pname位置互换 coutpNameendl; } student::student(student s) { coutCopy Constructor; if(s.pName) { int le

文档评论(0)

1亿VIP精品文档

相关文档