![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
||||
|
||||
Error: (function) undeclared -first use of this functionI don't understand why I'm getting these error messages. I have the .h file included in both the main program and the implementation file. The "undeclared" functions are reduce, gcf, and lcd, all having a problem in the main file. Do I need to move these functions to the main program file or am I not referencing them correctly in the header?
Here's the main file (rationalnum.cpp) CPP / C++ / C Code:
Here's the header file (ratnum.h) CPP / C++ / C Code:
Here's the implementation file (ratnum.ccp) CPP / C++ / C Code:
Thanks for the help. __________________
Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#2
|
||||
|
||||
|
Quote:
__________________
Age is unimportant -- except in cheese |
|
#3
|
||||
|
||||
|
Quote:
These functions are actually methods belonging to the RatNum class. You need to use them appropriately: CPP / C++ / C Code:
Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#4
|
||||
|
||||
|
Quote:
For reference, the error was Code:
__________________
Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#5
|
||||
|
||||
|
Quote:
__________________
Age is unimportant -- except in cheese |
|
#6
|
||||
|
||||
Fixed one problem, now have anotherI figured out the fix for the original problem (needed to move the default and explict constructors from the header file to the implementation file). Now I have a question about overloading operators.
If I want to overload a '+' sign, it's fairly easy w/ integers. CPP / C++ / C Code:
However, since my program deals w/ rational numbers, how do I pass the rational numbers into the overload function? Originally I used the this keyword until I realized that the compiler didn't understand what I wanted by telling me there was no matching function. Code:
Here's what I originally had: CPP / C++ / C Code:
The way I interpret the error message is that I can't use this because it's a pointer, not an object. If this is true, then how can I pass the original numbers to the overloaded operator? Is it as easy as adding another argument to the operator function? (The books I've looked at only show one argument). __________________
Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#7
|
||||
|
||||
|
Quote:
Sorry about this answer, I didn't look through your entire program (missed/disregarded the overloading stuff). So I suggest you also "disregard" my answer, OK ?Sorry again, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
Meeting the local Iraqis by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to interpret characters as they are being entered? | nkhambal | C Programming Language | 18 | 14-Feb-2006 10:41 |
| Revising Script style ?????? | pepee | MySQL / PHP Forum | 4 | 14-Apr-2004 04:59 |
| Another problem dealing with main() and driver function | tommy69 | C Programming Language | 4 | 20-Mar-2004 19:46 |
| Calling functions within a function | spudtheimpaler | C Programming Language | 5 | 02-Mar-2004 08:02 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The