1

I'm trying to write a program in complex arithmatic for my math class. The text I have gives me the following for addition:

typedef struct FCOMPLEX {float r,i;} fcomplex;
fcomplex Cadd(fcomplex a, fcomplex b)
{
fcomplex c;
c.r=a.r+b.r;
c.i=a.i+b.i;
return c;
}

but my compiler refuses to accept it. it gives me the following:
non-local function `main()::fcomplex Cadd(main()::FCOMPLEX, main()::FCOMPLEX)' uses
and then proceeds to tell me that my variables are neither int, double, nor float.
I have iomanip, iostream, and cmath as my included libraries. One of my books doesn't even list complex arithmatic while the other only shows me the various code pieces. I can't figure out how to make the program do what I want it to do. Help?

Thanks!

2
Contributors
2
Replies
3
Views
13 Years
Discussion Span
Last Post by fyrphnx
0

Hard to tell from what you posted, but having 'main()::' in the error is awfully suspicious. Is CAdd and the FCOMPLEX definition OUTSIDE of main()? as in:

typedef ...
CAdd()...
{
}

int main( ...)
{
}

0

The only things outside the int main() part are the include libraries. I've tried to work through this problem since I posted this initially. If ound another website that gives me a little bit of information on the subject as well, but it doesn't seem to work either. it deals with a class complex.
Thanks though.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.