|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
overloading operators..Plesae help
I have many errors when I compiled it. I think it's all from overloading operator. I have so many errors...this is one of them
binary '+' : no operator defined which takes a right-hand operand of type 'class FuelPurchase' (or there is no acceptable conversion. Can anyone fix please this for me? Here's my coding Header file of vehicle PHP Code:
source file of Vehicle PHP Code:
this si header file for journey PHP Code:
this is source file file journey PHP Code:
here's the header file for FuelPurchase PHP Code:
This is source file for FuelPurchase PHP Code:
Here's the main code... PHP Code:
Last edited by Tozilla : March 29th, 2003 at 01:19 AM. |
|
#2
|
|||
|
|||
|
I think you're right the problem is withing the overloading.
I didn't look through the code too carefully, but one thing that flagged me was the declarations for the overloaded operators. perhaps try something like: Journey operator +(const Journey& m) const; and then change the appropriate type for the other declaration. I'm not exactly sure what type incrimenting FuelPurchase will do, but try changing the return types in the declaration and implementation. |
|
#3
|
|||
|
|||
|
Here are two problems:
const operator +(const Journey& m) const; const operator +(const FuelPurchase& f) const; What are the return types of those two functions? Also, when you post an error message and several hundred lines of code, it would be very helpful if you posted the line the error occurred on. Last edited by 7stud : March 30th, 2003 at 03:33 AM. |
|
#4
|
|||
|
|||
|
Quote:
you mean the error message? I only got three error messages: vehicle.cpp(13) : error C2143: syntax error : missing ';' before 'PCH creation point' vehicle.cpp(38) : error C2511: '+' : overloaded member function 'class Vehicle (const class Journey &)' not found in 'Vehicle' vehicle.h(15) : see declaration of 'Vehicle' vehicle.cpp(46) : error C2511: '+' : overloaded member function 'class Vehicle (const class FuelPurchase &)' not found in 'Vehicle' vehicle.h(15) : see declaration of 'Vehicle' |
|
#5
|
|||
|
|||
|
Most people, including me, are not going to count lines to find out where the error is. If you can't take the time to comment your code to point to the lines where the errors are, I don't think you should expect people to take the time to help you.
|
|
#6
|
|||
|
|||
|
Quote:
you mean the error message? I only got four error messages: PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
Last edited by Tozilla : March 30th, 2003 at 03:50 AM. |
|
#7
|
|||
|
|||
|
Now I refer you to the first four lines of my initial post.
|
|
#8
|
|||
|
|||
|
Quote:
It should be like this for returning values? PHP Code:
PHP Code:
|
|
#9
|
|||
|
|||
|
yes..it's the same
|