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.
#include<iostream>
usingnamespace 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);