Write a Class that can Score Department id and Department name

0
6
digitalample eye
Write a class that can score department id and department name with the constructor 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();
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here