You are on page 1of 4

OOPS ASSIGMENT-2

PROGRAM:1

#include<iostream>
using namespace std;
class nhce
static int count;
public:
nhce()
{
count++;
cout<<"Object is being created”<<endl;
}
void show()
{
cout« ajay”,length of lines : 6”«"\n";
.”

}
,
nhce()
{
cout<<"Object is being deleted"<<endl;
-
};
int nhce ::count;
int main()

nhce s;
s.show();
return 0;
OUTPUT
Object is being created ajay length of lines : 6 Object is being
deleted
Process exited after 5.63 seconds with return value 0 Press any key to
continue . . .
PROGRAM:2
#Include<iostream>
using namespace std;
class Time {
private:
int hours;
int minutes;
public:
Time(){
hours=0;
minutes=8;
}
Time(int hint m){
hours=h;
minutes=m
}
void displayTime(){
cou«“H”:”«hours«”M"«minutes«endl;
}
Tie operator++(){
++minutes;
if(minutes>=60){
++hours;
minutes.60;
return Time(hours,minutes);
}
Time operator++(int){
Time T(hours,minutes);
++minutes;
if(minutes>=60){
++hours;
minutes-.68;
}
return T;
}
int main(){
Time T1(11,59),T2(10,48);
++T1;

Tl.displayTime();
++Tl;
Tl.displayTime();
T2++;
72.displayTime();
T2++;
T2.displayTime();
cout<<“ajay” ;
.

return 0;
}
OUTPUT:

H 12M: 60
H : 13M: 60
H : 10M:41
H : 10M:42
ajay
Process exited after 8.02 seconds with return value 0
Press any key to continue . . .
PROGRAM-3
include<iostream>
using namespace std; class nhce
{
static int count;
public:
nhce()
{
count++,
}
void show ()
{
cout<<“COUNT:”<<count« \n";
.

};
int nhce ::count,
int main()
nhce R,5;show();
cout<<“ajay”;
return 0
}

OUTPUT

COUNT-2
ajay
………………………………….. . .

You might also like