Ad Code

Responsive Advertisement

Operator over loading in C++.








programs of Operator over loading  :

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

class A{
 int a;
 int c;
 public:
 void set_a(int a1){
  a=a1;
 }
 int get_a(){
  return a;
 }
 A operator +(A&obj){
  A obj3;
  obj3.c=a+obj.a;
  return obj3;
 }
 int get_c(){
  return c;
 }
}; 
int main(){
 A obj,obj2,obj3;
 obj2.set_a(2);
 obj.set_a(2);
 obj3=obj+obj2;
 cout<<obj3.get_c();
}



out put:
 4



If you like code with vibhu  and would like to contribute, you can also write an article using   This link :

https://docs.google.com/forms/d/e/1FAIpQLScAmvlPvNUz35R-G0nc_zpRVP3o8xlhtFgC3aKPyLetX_RyXg/viewform?pli=1


OR  mail your article to bibhutiswain990@gmail.com.  See your article appearing on the code with vibhu main page and help other students. 
❮ Previous                                                      Next ❯

Post a Comment

0 Comments