You can't define a function within a function. here you define area()
inside main().
Proper ANSI C++ code:
int area( int s1, int s2);
int main()
{
int vol;
vol = area(12, 13);
return 0;
}
int area( int s1, int s2 )
{
return s1*s2;
}
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Peter Cartwright
> Sent: Tuesday, October 02, 2001 10:21 AM
> To: dev c++
> Subject: [Dev-C++] Dev - C++ function syntax problem
>
>
> Hello I started learning C++ a week ago, and was beginning
> to think it
> wasn't half as difficult as it's made out to be. Then I
> tried a minimalist
> program to demonstrate the syntax of calling a function.
>
> With the program below I get the compiler message " parse
> error before
> '{' " relating to opening curly bracket of return s1* s2.
> Any ideas about
> what is wrong, nothing I do cures it.
>
> #include <iostream.h>
> int area( int s1, int s2);
> int main()
> {
> int vol;
> vol = area(12, 13);
> int area( int s1, int s2 )
> {
> return s1*s2;
> }
> return 0;
> }
>
> From Peter Cartwright
>
>
> _______________________________________________
> Dev-cpp-users mailing list Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|