PLEASE Help this C++program Create an inheritance hierarchy for Asset / Furnitur
ID: 3689616 • Letter: P
Question
PLEASE Help this C++program
Create an inheritance hierarchy for
Asset / Furniture / Hardware / Software / Cubicle / Chair / Server / Laptop
Asset
Data members
- manufacturer
- purchase date
- cost
Hardware
Data members
- model
Software
Data members
-title
1. Instantiate an object for each type: Chair, Laptop, Software.
2. Provide data to initialize the data members of the objects.
3.Write getter functions that will display all the information stored in each object.
4. Use the getter function written in step 3 to display the information stored in the objects.
Explanation / Answer
#include<iostream.h>
#include<conio.h>
#include<string.h>
class Asset
{
public:
char manufacturer[20];
double cost;
};
class Hardware: public Asset
{
public:
char model[20];
Hardware(char m[], double c, char mo[])
{
strcpy(manufacturer,m);
cost=c;
strcpy(model,mo);
}
void print()
{
cout<<manufacturer<<endl;
cout<<cost<<endl;
cout<<model<<endl;
}
};
class Software: public Asset
{
public:
char title[20];
Software(char m[], double c, char t[])
{
strcpy(manufacturer,m);
cost=c;
strcpy(title,t);
}
void print()
{
cout<<manufacturer<<endl;
cout<<cost<<endl;
cout<<title<<endl;
}
};
void main()
{
Hardware Chair("aaa",20.5,"qwe");
Hardware Laptop("bbb",200.5,"zzz");
Software Soft("ccc",250.6,"nnnn");
Chair.print();
Laptop.print();
Soft.print();
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.