by Dinesh Thakur Category: Operator


#include <iostream.h>

class Values
                  int a,b;
                  Values() {}
                  Values(int aa, int bb)
                       void show()
                       cout <<a <<" ";
                       cout <<b <<"\n";
                       Values operator + (Values p);
                      Values Values :: operator + (Values p)
                         Values temp;
                         temp.a =p.a +a;
                         temp.b =p.b +b;
                         return temp;
                        void main()
                       Values v1(20,30),v2(15,40);
                       v1 =v1 +v2;

program for definition of operator+ ():

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.