Be easy on me. I'm new to this.
Just started using functions. Working from the book "Absolute C++"
I've written the code how I've been told to but keep getting this error -
error C2448: '<Unknown>' : function-style initializer appears to be a function definition
Heres the very basic test program I'm using. I've had to deviate from the book a little because I'm using Visual C++ 6.0 and it's complained about not initializing the variable seperately (hence the n1, n2, n3), and gave the above error for the following code, which I can't seem to get past...
#include <iostream>
usingnamespace std;
int n1;
int n2;
int n3;
int sum(int n1, int n2, int n3);
int main()
{
int sum(n1, n2, n3)
{
return ((n1 + n2) + n3);
}
cout << sum(7, 3, 80);
return 0;
}
Its probably something very basic that I'm missing. I'd appreciate any help.
#include <iostream>
usingnamespace std;
int n1;
int n2;
int n3;
int sum(int n1, int n2, int n3);
int main()
{
cout << sum(7, 3, 80);
return 0;
}
int sum(int n1, int n2, int n3)
{
return ((n1 + n2) + n3);
}