#include<conio>
#include<cstring.h>
#include<stdio.h>
class man
{
protected:
string name;
short age;
public:
man(string name,short age):name(name),age(age){
}
virtual void showattributes(){
}
};
class artist: public man{
private:
string alias;
public:
artist(string name,short age,string alias):man(name,age),
alias(alias){
}
void showattributes(){
cout << "artist" << name << age << alias << endl;
}
};
class lecturer : public man{
private:
string course;
public:
lecturer)string name,short age,string course):man(name,age),course(course){
}
void showattributes(){
cout << "lecturer " << name << age << course << endl;
}
};
int main(){
artist me ( " tukul " , 59, " arwana ");
lecturer u(" emergency ",17," c++ ");
man* it = &me
it->showattributes();
it = &u
it->showattributes();
getch();
};
Hasil OutPutnya :
0 Comments