Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by ggfrscff ( 7 years ago )
#include <iostream>
using namespace std;

class Student
{
	private:
	int roll;
	string name;

	public:

	static int no_admissions;
	static int no_cncl_admissions;

	Student()
	{
	}

	Student(string n)
	{
		name=n;
		no_admissions++;
		roll=no_admissions;
		

	}

	void setName(string n)
	{
		name=n;
		no_admissions++;
		roll=no_admissions;
		cout<<name<<" has been admitted with roll no : "<<roll<<endl;
	}

	~Student()
	{
		no_cncl_admissions++;
		cout<<name<<" cancelled admission."<<endl;
	}

	void display_admissions()
	{	
		cout<<"total number of admissions : "<<no_admissions<<endl;
	}

	void display_cncl_admissions()
	{	
		cout<<"total number of cancelled admissions : "<<no_cncl_admissions<<endl;
	}

};

int Student::no_admissions=0;
int Student::no_cncl_admissions=0;


int main()
{
	Student std[60];
	
	int action;
	int i=0;
	string name;
	int r;
	
	while(true)
	{
		cout<<"Enter number of the action to be performed"<<endl;
		cout<<"1. new Admission "<<"\n"<<"2. Cancellation "<<"\n"<<"3. Exit"<<endl;

	cin>>action;
	
	if(action==3)
	{
		break;
	}
	else if(action==1)
	{
		cout<<"Enter name : ";
		cin>>name;
		std[i].setName(name);
		std[i].display_admissions();
		std[i].display_cncl_admissions();
		i++;
	}
	else if(action==2)
	{
		cout<<"Enter roll : ";
		cin>>r;
		std[r-1].~Student();
		std[i].display_admissions();
		std[i].display_cncl_admissions();
	}
	}
}

 

Revise this Paste

Your Name: Code Language: