728x90 AdSpace

Latest Article



Manager Department Class Implementation in C++ Programming Code Example





Manager Department Class Implementation in C++ Programming Code Example Home Assignment
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

class Manager
{
   public:  
     string mname;                
     Manager(string n){
           mname = n;
     }

     const bool operator==(const Manager& m2)
     {
    if (m2.mname == mname)
     return true;
   else
     return false;
     }
};

class Dept
{
     
   public:
     string dname;
     Manager* m;

     Dept(string n, string mn)
     {
        dname = n;
        m = new Manager(mn);
        cout<<dname<<" dept const called"<<endl;
     }
     ~Dept()
     {      
        cout<<dname<<" dept dest called"<<endl;
        delete m;    
     }
   
     Dept(const Dept& d)
     {
         cout<<dname<<" dept copy constructor called "<<endl;            
         dname = d.dname;

         m = new Manager(d.m->mname);
   
     }
   
   
   
   
   

};


void tester(Dept x)
{

}

int main()
{
  Manager m1("ABCD");
  Manager m2("ABCD");

    if (m1 == m2)
       cout << "MATCHED" << endl;
    else
   cout << "NOT MATCHED" << endl;

  system("pause");
}


no image
  • Title : Manager Department Class Implementation in C++ Programming Code Example
  • Posted by :
  • Date : 03:58
  • Labels :






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment