#include<iostream>
using namespace std;
class medicine
{
protected:
string medicine_name,company_name;
int medicine_price;
public:
virtual void info()=0;
};
class tablet:public medicine
{
private:
string tablet_type;
int tablet_size;
public:
tablet(string w,string x,int y,string z,int v)
{
medicine_name=w;
company_name=x;
medicine_price=y;
tablet_type=z;
tablet_size=v;
}
void info()
{
cout<<"name of the tablet is:"<<medicine_name<<endl;
cout<<"name of the tablet company is:"<<company_name<<endl;
cout<<"price of the tablet is:"<<medicine_price<<endl;
cout<<"type of the tablet is:"<<tablet_type<<endl;
cout<<"size of the tablet is:"<<tablet_size<<endl;
}
};
class syrup:public medicine
{
private:
string syrup_type,syrup_colour;
public:
syrup(string w,string x,int y,string z,string v)
{
medicine_name=w;
company_name=x;
medicine_price=y;
syrup_type=z;
syrup_colour=v;
}
void info()
{
cout<<"name of the syrup is:"<<medicine_name<<endl;
cout<<"name of the syrup company is:"<<company_name<<endl;
cout<<"price of the syrup is:"<<medicine_price<<endl;
cout<<"type of the syrup is:"<<syrup_type<<endl;
cout<<"colout of the syrup is:"<<syrup_colour<<endl;
}
};
int main()
{
medicine *obj1;
tablet obj2("Lantus Solostar","Pfizer Inc",200," Film-Coated Tablets",2);
syrup obj3("Tylenol","Novartis AG",500,"Chocolate syrup","red");
obj1=&obj2;
cout<<"\t\t\ttablet class..."<<endl;
obj1->info();
cout<<"\t\t\tsyrup class..."<<endl;
obj1=&obj3;
obj1->info();
}
No comments:
Post a Comment