/*
* Copyright (c) 2014, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作 者:阿里木·阿布都热合曼
* 完成日期:2015年 5月 20 日
* 版 本 号:v1.0
*
* 问题描述:
* 输入描述:
* 程序输出:
*/
代码:
#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("春哥",19);
s.display1();
return 0;
}
运行结果:
知识点总结:
主要运用了函数的调用问题。
学习心得:
通过这个项目的编程我更加熟练的的学会了构造函数的定义以及声明,除此之外还有函数之间的调用。
自我勉励:
I am the best!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!