[ create a new paste ] login | about

Link: http://codepad.org/DsoeDiyJ    [ raw code | output | fork ]

C++, pasted on May 30:
#include<iostream>
#include<string>
using namespace std;
class Person
{
private:
	char *name;
public:
	Person(char *n1):name(n1){strcpy(name,n1);}
	void PrintName() {cout<<"The name is:" << name;}
};
class Student:public Person
{
private:
	long int Number;
public:
	Student(char *n2,long int n3):Person(n2) {Number=n3;}
	void PrintInfo() {cout<<"The number is:" << Number;}
};
int main()
{
	char ch[]="张三";
	Person a(ch);
	a.PrintName();
	cout<<endl;
	Student b(ch,142180217);
	b.PrintInfo();
	cout<<endl;
	return 0;
}


Output:
1
2
The name is:张三
The number is:142180217


Create a new paste based on this one


Comments: