峥怎么读音是什么:c++编程问题
来源:百度文库 编辑:高校问答 时间:2024/04/26 17:57:09
老大,处理了
要到期了
#include<cstring>
#include<iostream>
using namespace std;
class Student {
protected:
char name[ 10 ],
*id;
public:
Student( char *name, char *id ) : id( id ) {
strncpy( this->name, name, 10 );
}
virtual char *getName( ) = 0;
virtual char *getID( ) = 0;
};
class MajorStudent : public Student {
char *Major;
int Cost;
public:
MajorStudent( char *name, char *id, char *Major, int Cost )
: Student( name, id ), Major( Major ), Cost( Cost ) { }
char *getName( ) { return name; }
char *getID( ) { return id; }
char *getMajor( ) { return Major; }
int getCost( ) { return Cost; }
};
main( ) {
MajorStudent ms( "Mr. Major", "9975102", "Minority Culture", 20000 );
cout << "Particulars Of A Major Student:" << "\n\n"
<< "Name: " << ms.getName( ) << endl
<< "ID: " << ms.getID( ) << endl
<< "Major In: " << ms.getMajor( ) << endl
<< "Cost Of Major (US$): " << ms.getCost( ) << "\n\n";
return 0;
}