Write a Class that can Score Department id and Department name

Write a class that can score department id and department name with the construct or to initialize its members. Write destructor member in the same class and display the message “Object n goes out of scope”. Here program should be made such that it should show the order of constructor and destructor invocation.

Write a class that can score department id and department name with the construct or to initialize its members. Write destructor member in the same class and display the message “Object n goes out of scope”. Here program should be made such that it should show the order of constructor and destructor invocation.


C++ CODE

\
#include<iostream.h>
#include<conio.h>
class scores
{
 private:
  int n;
  static int count;
  int id;
  int *dname;
 public:
  scores(int a, char *p)
  {
   id=a;
   *dname=*p;
                        count++;
                        
  }
 
  ~scores()
  {
   cout<<"Object "<<count <<"goes out of scope."<<endl;
                        count--;
  }
};
int scores::count;
void main()
{
 scores s1(001,"IT");
 
 scores s2(002,"HR");
  
 scores s3(003,"MGMT");
 getch();
}

You May Also Like...

Socialize with Us