176. Write a program to perform addition of two object using friend function?

#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 →

Advertisements

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 →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: