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

Using c++ language a) Create a class called \'Enterprize\', it has one private m

ID: 3821103 • Letter: U

Question

Using c++ language a) Create a class called 'Enterprize', it has one private member 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. b) Create a derived class (of Enterprise) 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. c) 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. d) Define all the functions (no need of default constructors). e) 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 SIM revenue and deals with food. f) 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

class Enterprize{
   private:
       char category;

   public:
       Enterprize(char c){
           category=c;
       }
   char getCategory(){
       return category;
   }
};

class not_for_profit: public Enterprize{
   private:
       char sponsor;
       public:
       not_for_profit(char c, char cat)
       : Enterprize(cat)
       {
           sponsor=c;
       }
   char getSponsor(){
       return sponsor;
   }
};

class for_profit: public Enterprize{
   private:
       int revenue;
       public:
       for_profit(int c, char cat)
       : Enterprize(cat)
       {
           revenue=c;
       }
   char getRevenue(){
       return revenue;
   }
};
int main()
{
   not_for_profit Salvation_army('P','C');
   for_profit HEB(1000000,'F');
   if(Salvation_army.getCategory()==HEB.getCategory())
   {
       printf("They are in same category");
   }
   else
   {
       printf("They are not in same category");
   }
}

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