#include<iostream.h> #include<conio.h> class addition { private: int a,b; public: addition() { } addition(int p,int q) { a=p; b=q; } void display() { cout<<"A = "<<a<<"\tB = "<<b<<endl; } friend addition operator + (addition obj1,addition obj2); ; //Operator function as friend function... Continue Reading →
175. Write a program to perform addition of two object using operator keyword?
#include<iostream.h> #include<conio.h> class addition { private: int a,b; public: addition() { } addition(int p,int q) { a=p; b=q; } //Operator function as member function which is called by object 'x' (Left Operator) addition operator + (addition obj) { addition t; t.a=a+obj.a; ... Continue Reading →
Order of execution of constructor and destructor: –
Order of execution of constructor and destructor: - The order of execution of constructor goes from low to high. Where order of execution of destructor goes from high to low. Explicit call to constructor and destructor: - We have two technique to explicit call to the constructor. Syntax: - (1) Without object name Class_Name();... Continue Reading →
Destructor: –
Destructor: - It is also a special member function just like constructor. The purpose of it is to destroy the memory allocation of an object. When the object goes out of the scope when the object are created. There are following some rule – It must also have same name as of its class name... Continue Reading →