![]() |
| ||
| Trouble writing code for arithmetic calculations of complex numbers 2 Attachment(s) I'm taking CMIS140, and I have a project using complex numbers. I can't figure out how to write the calculations into the program. I have attached the project, and the code I have written at this point. If anyone has any suggestions on how to do this, I would appreciate it. |
| ||
| Re: Trouble writing code for arithmetic calculations of complex numbers paste your code inside code tags instead of attaching the sourcefiles. M Makes it a lot easier for everyone to see what you're talking about. And posting your assignment verbatim doesn't help either (but at least you're honest stating it's a school assignment ;)). Now for a bit of help to get you started. I've yesterday for fun and training (I've been more or less out of C++ for years, starting to get pretty rusty) created a class that does addition and subtraction of complex numbers. The rest you can easily think up to do yourself, they work similarly. I'll not post the full implementation (which is pretty trivial) nor the test application (which is even more trivial), but the headerfile giving all function prototypes. That should give you enough hints to get started implementing the system yourself. #include <iostream> you can of course include far more functionality than this, but this should be a good start. |
| ||
| Re: Trouble writing code for arithmetic calculations of complex numbers Thank you for your help, and it did help. Now I keep getting the following error, and I don't know what it means. error C2556: 'int __thiscall ComplexNumbers::AddComp(const class ComplexNumbers &,const class ComplexNumbers &)' : overloaded function differs only by return type from |
| ||
| Re: Trouble writing code for arithmetic calculations of complex numbers You probably made a typo somewhere in the return type of a function. If you define 2 functions of the same name (overloaded functions) in the same namespace (or class) they are required to have different argument lists else the compiler and runtime don't know which function to call. |
| ||
| Re: Trouble writing code for arithmetic calculations of complex numbers >they are required to have different argument lists Or constness for member functions. The following introduces no ambiguity yet the return types and argument lists for the overloaded function are identical: #include <iostream> |
| ||
| Re: Trouble writing code for arithmetic calculations of complex numbers i am not able to run the program on complex numbers can any one help me out |
| ||
| Re: Trouble writing code for arithmetic calculations of complex numbers what code are you talking about? |
| All times are GMT -4. The time now is 12:48 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC