#include"iostream.h"class CPerson{private: char *name;public: CPerson(char *s); virtual ~CPerson();};class CPerson::CPerson(char *s){ name=new char[strlen(s)+1]; strcpy(name,s);}class CPerson::~CPerson(){ if(name) { delete []name; }}class CStudent::public CPerson{private: char *major;public: CStudent(char *s,char *m); virtual ~CStudent();}class CStudent::CStudent(char *s,char *m){ name=new char[strlen(m)+1]; strcpy(major,m);}class CPerson::~CPerson(){ if(major) { delete []major; }}void main(){ CPerson *p=new CStudent("zhang","computer science"); delete p;}//这是编译出现的错误代码:fatal error C1004: unexpected end of file found
1 回答
- 1 回答
- 0 关注
- 974 浏览
添加回答
举报
0/150
提交
取消