I'm trying to define the formula for the surface of a cube and than to call it in the code but I have a syntax error on the calling line. I think maybe i should use something different then SQRE but i don't know what .
int main()
{
int a, b, c,P;
cout << "Please enter the lenght's of the site's: ";
cout << "Lenght of site a: ";
cin >> a;
cout << "Lenght of site b: ";
cin >> b;
cout << "Lenght of site c: ";
cin >> c;
P = SQRE(a, b, c);
cout<< P<< endl;
return 0;
}
You are using or misunderstanding the "#define". The compiler sees P = SQRE(a,b,c) as a call to a function, but the preprossor sees "SQRE" and replaces it with (a,b,c) 2*(a*b+a*c+b*c) and the entire lin would read P = (a,b,c) 2*(a*b+a*c+b*c)(a,b,c);. You will not see this replacement in your code, but it will be done when the code is compiled thus giving you an error.
You might try changing the "#define" to just 2*(a*b+a*c+b*c) and see what happens or write a function that returns an int.
Andy thank you very much this sounds very logical to me but i can make a function but i would like to do it like I "define" and if a change it a I still need to call it somehow i need a name of the "define"