Add two number using class in c++ .

 HOW to add two number using class in c++


i will give only example -      how to add -



 

example -   #include  <iostream>

                      using namespace std;

                      

                       class add {

                        int a,b,c;

                        public:

                         int addition(int x,int y);

                          

                           };

                       int add::addition(int x,int y) {

                          return(x+y);

                                                  }

      

                        int main() { 

                        add a1;

                        int c=a1.addition(5,6);





                          cout<<"sum is :"<<c;

                          }






output----- sum is 11.
  



try it yourself -


                          

Comments

Popular posts from this blog

In C++ Syntax

DATA types in C++ languages .