/*
*Copyright(c)2014,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:曾晓
*完成日期:2015年 5月 19日
*版本号:v1.0
*/
#include <iostream>
#include <cstring>
using namespace std;
class Person{
public:
Person(char* s){
strcpy(name,s);
}
void display( ){
cout<<"Name: "<<name<<endl;
}
private:
char name [20];
};
class Student:public Person
{
public:
Student(char* s, int g):Person(s)
{grade=g;}
void display1( )
{
display();
cout<<"Grade: "<<grade<<endl;
}
private:
int grade;
};
int main( )
{
Student s("0歌",19);
s.display1();
return 0;
}
运行结果:
哈哈哈昨天上课的时候就说这个项目要写凌歌 她还说你敢 ><