Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help would be greatly appreciated (Class and Derived Class) Create a class calle

ID: 3839450 • Letter: H

Question

Help would be greatly appreciated

(Class and Derived Class) Create a class called 'Enterprize', it has one private variable called 'category' (of character type, its value is either 'F' (for food), or 'C' (for clothing), or 'H' (for housing)). This class should have constructor and accessor functions. Create a derived class (of Enterprize) called 'not_for_profit' having one private member variable called 'sponsor' (of character type, its value is either 'P' (for private), or 'G' (for government)). This derived class should also have constructor and accessor functions. Create another derived class (of Enterprize) called 'for_profit' having one private member variable called "revenue" (of integer type). This derived class should also have constructor and accessor functions. Define all the functions (no need of default constructors). In the main function, declare one object (called Salvation_army) of class 'not_for_profit' that has private sponsor and deals with clothing. Declare another object called HEB) of class for profit" that has private sponsor and deals with clothing. Declare another object (called HEB) of class 'for_profit' that has $1M revenue and deals with food. Write statements to check if Salvation_army and HEB are in the same category of Enterprize or not (food, clothing. or housing) and print appropriate messages.

Explanation / Answer

#include<iostream>
using namespace std;

class Enterprize //base class
{
private:
char category;
  
public:
Enterprize(char category) // argument constructor
{
this->category = category;
}
char getCategory() //accessor method
{
return category;
}
  
};

class not_for_profit: public Enterprize //derived class
{
private:
char sponsor;
  
public:
//passing argument to base class throught constructor
not_for_profit(char sponsor,char category):Enterprize(category)
{
this->sponsor = sponsor;
}
char getSponsor()
{
return sponsor;
}
  
};
class for_profit: public Enterprize
{
private:
int revenue;
  
public:
//passing argument to base class throught constructor
for_profit(int revenue,char category):Enterprize(category)
{
this->revenue = revenue;
}
char getRevenue()
{
return revenue;
}
  
};
int main()
{
  
not_for_profit Salvation_army('P','C');
for_profit HEB(1000000,'F');
  
if(Salvation_army.getCategory() == HEB.getCategory())//compare categories
cout<<" Salvation_army has same category as that of HEB";
else
cout<<" Salvation_army does not have same category as that of HEB";


return 0;
}

Output:

Salvation_army does not have same category as that of HEB

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote