0% found this document useful (0 votes)
11 views1 page

Void Main

The code defines a class called Arithmetic with a constructor and destructor. It creates 4 Arithmetic objects with different constructors - a default constructor, a single parameter constructor, a two parameter constructor, and a copy constructor. It calls the calculate method for each object, displaying the output of each calculation based on the constructor parameters.

Uploaded by

sathyasony
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
11 views1 page

Void Main

The code defines a class called Arithmetic with a constructor and destructor. It creates 4 Arithmetic objects with different constructors - a default constructor, a single parameter constructor, a two parameter constructor, and a copy constructor. It calls the calculate method for each object, displaying the output of each calculation based on the constructor parameters.

Uploaded by

sathyasony
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 1

void main() { clrscr(); int x,y,z; cout<<"CONSTRUCTOR & DESTRUCTOR"; Arithmetic obj1; obj1.

calculate(); cout<<"Enter one value"<<endl; cin>>x; Arithmetic obj2(x); obj2.calculate(); cout<<"Enter two values"<<endl; cin>>y>>z; Arithmetic obj3(y,z); obj3.calculate(); Arithmetic obj4(obj1); obj4.calculate(); getch(); } Output CONSTRUCTOR & DESTRUCTOR Sum using default constructor a=5 b=10 sum=15 Enter one value 23 Sum using single parameter constructor a=23 b=100 sum=123 Enter two values 12 6 Sum using parameterised constructor having two parameter a=12 b=6 sum=18 Sum using copy constructor a=5 b=10 sum=15

You might also like