You are on page 1of 2

#include<iostream>

#include<string>
using namespace std;
class absemploye{
virtual void askforpromotion() = 0;
};
class employee:absemploye{
protected:
string name;
string sex;
int age;
public:
employee(string iname,string isex,int iage){
name = iname;
sex = isex;
age = iage;
}
void setname(string iname){
name = iname;
}
string getname(){
return name;
}
void setsex(string isex){
sex = isex;
}
string getsex(){
return sex;
}
void setage(int iage){
age = iage;
}
int getage(){
return age;
}
void display(){
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"age:"<<age<<endl;
cout<<"\n--------------------"<<endl;
}
void askforpromotion(){
if(age>18)
cout<<"you promoted "<<endl;
else
cout<<"you are not get promoted"<<endl;
}
};
class human:public employee{
public:
string career;
human(string name,string sex,int age,string icareer)
:employee(name,sex,age){
career = icareer;
}
void displlay(){
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"age:"<<age<<endl;
cout<<"career:"<<career<<endl;
cout<<"\n--------------------"<<endl;
}
};
class shape{//base class
protected:
int width;
int length;
public:
shape(int a,int b){
width = a;
length = b;
}
};
class rectangle:public shape{
public:
rectangle(int a,int b):shape(a,b){

}
int area(){
return width*length;
}
};
class triangle:public shape{
public:
triangle(int a,int b):shape(a,b){

}
int area(){
return double(width*length)/2;
}
};

int main(){
rectangle r1 = rectangle(4,5);
cout<<"area:"<<r1.area()<<endl;
//employee e1("anaol","male",20);
//.askforpromotion();
//human h1 = human("anaol","male",20,"engineer");
//h1.displlay();
return 0;
}
// demonistrate four
//abstraction
//encspsulation
//inheritance
//polymorphism

You might also like