论坛: 编程破解 标题: 哪错了? 复制本贴地址    
作者: cainiao110 [cainiao110]    论坛用户   登录
#include<iostream.h>
#include<string.h>
class PERSON{
PERSON(char*name,int age){
PERSON::name=new char[strlen(name)+1];
strcpy(PERSON::name,name);
PERSON::age=age;
cout<<"Construct person "<<name<<","<<age<<".\n";
return;
}
~PERSON()
{
cout<<"Destruct person "<<name<<","<<age<<".\n";
return;
}
protected:
char*name;
int age;
};
class TEACHER:virtual public PERSON{
public:
TEACHER(char*name,int age,char*teaching):PERSON(name,age)
{
couse=new char[strlen(teaching)+1];
strcpy(course,teaching);
cout<<"Construct teacher teaching "<<course<<",\n";
return;
}
~TEACHER()
{
cout<<"Destruct teacher teaching "<<course<<",\n";
delete couse;
return;
}
protected:
char*couse;
};
class STUDENT:virtual public PERSON{ 
public:
STUDENT(char*name,int age,char*tudying):PERSON(name,age)
{
course=new char[strlen(studying)+1];
strcpy(couse,studying);
cout<<"Construct student studying "<<course<<",\n";
return;
}
~STUDENT()
{
cout<<"Destruct student studying "<<couse<<",\n";
delete course;
return;
}
protected:
char*couse;
};
class IN_SERVICE:virtual public TEACHER,virtual public STUDENT{
public:
IN_SERVICE(char*name,int age,char*teaching,char*studying):
  TEACHER(name,age,teaching),
  STUDENT(name,age,studying),
  PERSON(name,age)
  {
  cout<<"Construct an in_service "<<name<<" ";
  cout<<"teaching "<<TRECHER::couse<<" and ";
  cout<<"studying "<<STUDENT::couse<<".\n";
  return;
  }
  ~TEACHER()
  {
  cout<<"Destruct an in_service "<<name<<" ";
  cout<<"teaching "<<TRECHER::couse<<" and ";
  cout<<"studying "<<STUDENT::couse<<".\n";
  return;
  }
};
void main()
{
PERSON*person;
person=new PERSON("Leeman",30);
delete person;
}
//是C++程序

地主 发表时间: 06/16 16:01

回复: cimsxiyang [cimsxiyang]   版主   登录
你先把该帖子中起码的空格错误去掉。我眼花。

B1层 发表时间: 06/16 23:24

回复: runwin [runwin]   论坛用户   登录
我看去很多破东西::(

B2层 发表时间: 06/17 01:47

回复: NetDemon [netdemon]   ADMIN   登录
这样就好多了

代码:

#include<iostream.h>
#include<string.h>
class PERSON{
PERSON(char*name,int age){
PERSON::name=new char[strlen(name)+1];
strcpy(PERSON::name,name);
PERSON::age=age;
cout<<"Construct person "<<name<<","<<age<<".\n";
return;
}
~PERSON()
{
cout<<"Destruct person "<<name<<","<<age<<".\n";
return;
}
protected:
char*name;
int age;
};
class TEACHER:virtual public PERSON{
public:
TEACHER(char*name,int age,char*teaching):PERSON(name,age)
{
couse=new char[strlen(teaching)+1];
strcpy(course,teaching);
cout<<"Construct teacher teaching "<<course<<",\n";
return;
}
~TEACHER()
{
cout<<"Destruct teacher teaching "<<course<<",\n";
delete couse;
return;
}
protected:
char*couse;
};
class STUDENT:virtual public PERSON{ 
public:
STUDENT(char*name,int age,char*tudying):PERSON(name,age)
{
course=new char[strlen(studying)+1];
strcpy(couse,studying);
cout<<"Construct student studying "<<course<<",\n";
return;
}
~STUDENT()
{
cout<<"Destruct student studying "<<couse<<",\n";
delete course;
return;
}
protected:
char*couse;
};
class IN_SERVICE:virtual public TEACHER,virtual public STUDENT{
public:
IN_SERVICE(char*name,int age,char*teaching,char*studying):
  TEACHER(name,age,teaching),
  STUDENT(name,age,studying),
  PERSON(name,age)
  {
  cout<<"Construct an in_service "<<name<<" ";
  cout<<"teaching "<<TRECHER::couse<<" and ";
  cout<<"studying "<<STUDENT::couse<<".\n";
  return;
  }
  ~TEACHER()
  {
  cout<<"Destruct an in_service "<<name<<" ";
  cout<<"teaching "<<TRECHER::couse<<" and ";
  cout<<"studying "<<STUDENT::couse<<".\n";
  return;
  }
};
void main()
{
PERSON*person;
person=new PERSON("Leeman",30);
delete person;
}



大家慢慢看吧,我闪

B3层 发表时间: 06/17 01:50

回复: easyking [easyking]   论坛用户   登录
#include<iostream.h>
#include<string.h>

class PERSON{
public:
PERSON(char*name,int age){
PERSON::name=new char[strlen(name)+1];
strcpy(PERSON::name,name);
PERSON::age=age;
cout<<"Construct person "<<name<<","<<age<<".\n";
return;
}
~PERSON()
{
cout<<"Destruct person "<<name<<","<<age<<".\n";
return;
}
protected:
char*name;
int age;
};

class TEACHER:virtual public PERSON{
public:
TEACHER(char*name,int age,char*teaching):PERSON(name,age)
{
couse=new char[strlen(teaching)+1];
strcpy(couse,teaching);
cout<<"Construct teacher teaching "<<couse<<",\n";
return;
}
~TEACHER()
{
cout<<"Destruct teacher teaching "<<couse<<",\n";
delete couse;
return;
}
protected:
char*couse;
};
class STUDENT:virtual public PERSON{ 
public:
STUDENT(char*name,int age,char*studying):PERSON(name,age)
{
couse=new char[strlen(studying)+1];
strcpy(couse,studying);
cout<<"Construct student studying "<<couse<<",\n";
return;
}
~STUDENT()
{
cout<<"Destruct student studying "<<couse<<",\n";
delete couse;
return;
}
protected:
char* couse;
};

class IN_SERVICE:virtual public TEACHER,virtual public STUDENT{
public:
IN_SERVICE(char*name,int age,char*teaching,char*studying):
  TEACHER(name,age,teaching),
  STUDENT(name,age,studying),
  PERSON(name,age)
  {
  cout<<"Construct an in_service "<<name<<" ";
  cout<<"teaching "<<TEACHER::couse<<" and ";
  cout<<"studying "<<STUDENT::couse<<".\n";
  return;
  }
  ~IN_SERVICE()
  {
  cout<<"Destruct an in_service "<<name<<" ";
  cout<<"teaching "<<TEACHER::couse<<" and ";
  cout<<"studying "<<STUDENT::couse<<".\n";
  return;
  }
};
void main()
{
PERSON*person;
person=new PERSON("Leeman",30);
delete person;
}


B4层 发表时间: 06/24 20:34

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号