#include <iostream>
#include <cstring>
using namespace std;
class Person
{
public:
Person(const char* n, int i);
~Person();
void Display();
protected:
char* name;
int id;
};
class CollegeStu : public Person
{
public:
CollegeStu(const char* n, int i, const char* m, double s);
~CollegeStu();
void Display();
private:
char* major;
double score;
};
Person::Person(const char* n, int i)
{
name = new char[lbk]strlen(n) + 1[rbk];
strcpy(name, n);
id = i;
}
Person::~Person()
{
delete[lbk][rbk] name;
}
void Person::Display()
{
cout << "Name:" << name << endl;
cout << "ID:" << id << endl;
}
CollegeStu::CollegeStu(const char* n, int i, const char* m, double s) : Person(n, i)
{
major = new char[lbk]strlen(m) + 1[rbk];
strcpy(major, m);
score = s;
}
CollegeStu::~CollegeStu()
{
delete[lbk][rbk] major;
}
void CollegeStu::Display()
{
Person::Display();
cout << "Major:" << major << endl;
cout << "C++ Score:" << score << endl;
}
int main()
{
char name[lbk]81[rbk], major[lbk]81[rbk];
int id;
double score;
cin >> name >> id >> major >> score;
CollegeStu cs(name, id, major, score);
cs.Display();
return 0;
}
#include <cstring>
using namespace std;
class Person
{
public:
Person(const char* n, int i);
~Person();
void Display();
protected:
char* name;
int id;
};
class CollegeStu : public Person
{
public:
CollegeStu(const char* n, int i, const char* m, double s);
~CollegeStu();
void Display();
private:
char* major;
double score;
};
Person::Person(const char* n, int i)
{
name = new char[lbk]strlen(n) + 1[rbk];
strcpy(name, n);
id = i;
}
Person::~Person()
{
delete[lbk][rbk] name;
}
void Person::Display()
{
cout << "Name:" << name << endl;
cout << "ID:" << id << endl;
}
CollegeStu::CollegeStu(const char* n, int i, const char* m, double s) : Person(n, i)
{
major = new char[lbk]strlen(m) + 1[rbk];
strcpy(major, m);
score = s;
}
CollegeStu::~CollegeStu()
{
delete[lbk][rbk] major;
}
void CollegeStu::Display()
{
Person::Display();
cout << "Major:" << major << endl;
cout << "C++ Score:" << score << endl;
}
int main()
{
char name[lbk]81[rbk], major[lbk]81[rbk];
int id;
double score;
cin >> name >> id >> major >> score;
CollegeStu cs(name, id, major, score);
cs.Display();
return 0;
}










