Sep 2, 2013 at 10:02am UTC
Where is the error in the following code ?
The program is not printing anything ..
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 26 27 28 29 30 31 32 33 34 35 36
#include<iostream>
using namespace std;
class add
{
private :
int a;
int b;
private :
void set_ab(int i ,int j);
friend void sum();
};
void add::set_ab(int i,int j)
{
a=i;
b=j;
}
void sum()
{
add x;
x.set_ab(10,20);
cout << "Sum= " << x.a+x.b;
}
int main()
{
void sum();
return 0;
}
Using void was a mistake !!
BUT..
After removing void it is still not printing anything !!
Last edited on Sep 3, 2013 at 3:56pm UTC
Sep 2, 2013 at 10:14am UTC
This
void sum();
is not a function call. It is a function declaration.