#include<iostream>
#include<conio.h>
usingnamespace std;
class evs
{
private:
int k;
int b;
int result;
public:
int value ()
{
cout<<"enter value 1:";
cin>>k;
cout<<"enter value 2:";
cin>>b;
}
int sum ()
{
result=k+b;
cout<<"The sum of both numbers you entered is:"<<result<<endl;
}
int main()
{
evs aaa;
aaa.value();
aaa.sum();
getch();
}
}
i want to make a code that is based on class and object and is capable of getting input in first member function and sum up and give result in second member function.. i made this code but am getting some error with braces.. dont know weather its right or wrong.. any help in this regard will make you and me happy :)
buddy am confused in that some one told me that my whole code is wrong can you kindly chek that again.. and do me a favor copy that part of code and paste it here with correction..
#include<iostream>
#include<conio.h>
usingnamespace std;
class evs
{
private:
int k;
int b;
int result;
public:
void value () // Note: You don't want to return anything so void instead of int
{
cout<<"enter value 1:";
cin>>k;
cout<<"enter value 2:";
cin>>b;
}
void sum () // Note: void instead of int
{
result=k+b;
cout<<"The sum of both numbers you entered is: "<<result<<endl;
}
};
int main() // Note: main ouside the class
{
evs aaa;
aaa.value();
aaa.sum();
getch();
return 0; // Note: If you write 'int function()' you need to return a value
}