#include <iostream.h>
#include <string>
#define BUFSIZE 128 /*Constant using macro –no checking type*/
using namespace std; /*standard container class*/
class person{
public: /*Default constructor */
char *surname, *givename, *address, *birthday; /*also another
solution by switching completely to initializer lists, using
std::string instead of char*,using namespace std.*/
person(); /*definiton of person*/
person(char *sn, char *gn, char *addr, char *bDay){
surname=sn;
givename=gn;
address=addr;
birthday=bDay;
}
/*show new name*/
void nameChange(char *sname, char *gname){
surname=sname;
givename=gname;
cout<<"Name has been changed"<<endl;
}
/*show new address*/
void addrChange(char *addr){
address=addr;
cout<<"Address has been changed"<<endl;
}
/*show surname and givename*/
void showName(){
cout<<"Surname: "<<surname<<endl;
cout<<"Givename: "<<givename<<endl;
}
/*show addres*/
void showAddr(){ /*show addres*/
cout<<"Address: "<<address<<endl;
}
person(){}; /*recalls the properties of person*/
};
/*Student inherits form person*/
class student:public person{
private:
int studentNo; /*define student number as int*/
/*Student contructor*/
public:
student(char *sn, char *gn, char *addr, char *bDay, int sNo) /*also
changes to the construcotr stundent(const string &,const string
&,const string &,const string &,const int&);*/
:person(sn,gn,addr,bDay){
studentNo=sNo;
}
void showStudentNo(){
cout<<"Sudent No: "<<studentNo<<endl; /*also here could have been
optimised std::cout << "Student No: " << studentNo << std::endl:*/
}
};
int main(){
cout<<"----------person----------"<<endl;
person p1=person("Fausto", "Rstom", "YO-KYLA 2D 29", "06.02.73");
p1.showName();
p1.nameChange("Fausto","Rstom");
cout<<"Show name agian!"<<endl;
p1.showName();
cout<<"Show address!"<<endl;
p1.showAddr();
cout<<"---------student------------"<<endl;
student s1=student("Gherici", "Constantin", "Nostovaenkatu 20 as 13",
"21.05.73", 12345);
s1.showName();
s1.showStudentNo();
s1.showAddr();
s1.addrChange("Yo-kyla 10A 23");
cout<<"Show address agian!"<<endl;
s1.showAddr();
return 0;
}