Assignment - 2: Ariful Asfake Sunny 2223091008 58A Fall-22 (Eve), B.SC in Cse

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

UTTARA UNIVERSITY

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

ASSIGNMENT - 2

PREPARED BY :

ARIFUL ASFAKE SUNNY


STUDENT ID :

2223091008
SECTION AND BATCH :

58A FALL-22 (EVE), B.SC IN CSE


ASSIGNMENT NAME :

COUNT NUMBER OF OBJECT USING CONSTRUCTOR.

SUBJECT CODE : SUBMISSION DATE :

CSEC 211 & 212 25 JANUARY, 2023


#include <iostream>
#include <string.h>
using namespace std;

class Assignment
{
private:
static int count;

public:
string OutputTEXT;

public:
Assignment() {
count++;
}

void printMessage() {
cout << OutputTEXT << endl;
}

static int ObjectsKeeperFunction() {


return count;
}
};

int Assignment::count;

int main()
{
Assignment O1, O2, O3, O4, O5; //class to object

O1.OutputTEXT = "First time Class Call for first object creation \n";
O1.printMessage();

O2.OutputTEXT = "Second time Class Call for 2nd object creation \n";
O2.printMessage();

O3.OutputTEXT = "Third time Class Call for 3rd object creation \n";
O3.printMessage();

O4.OutputTEXT = "Fourth time Class Call for 4th object creation \n";
O4.printMessage();

O5.OutputTEXT = "Fifth time Class Call for 5th object creation \n";
O5.printMessage();

cout << "Our Total Objects: " << Assignment::ObjectsKeeperFunction() << endl;

return 0;
}

You might also like