problem with objects and classes

i have written down this program in codeblocks (gnu c++ compiler) using the
concept of classes and objects but when i compile it it should return 12 but when i compile .only thing i see is process returned 0.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<iostream>
using namespace std;

class kartikclass
{
public:
int add(int x,int y)
{


 return x+y;

}
};


int main()
{
    kartikclass kartikobject;
   kartikobject.add(5,7);
 return 0;

}

 the code you need help with here.
"process returned 0" just says that your program ran successfully.
You code is fine. It works just as you want it.
It called the add function and added 5 and 7.
To see the result, you need to tell the compiler to display it.
So add a cout statement before your function call.
1
2
//Line 20 should be like this:
cout << kartikobject.add(5,7);
thanks very much newbiee999
Topic archived. No new replies allowed.