|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
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
|
|||
|
|||
|
Operator overloading,initization, Print() in header file
I'm currently writing a header file for a Car class. But The problem is I don't know how to initialized in the Car class and use the copy constructor in the header file. Also, this header file requires a operator function. When I compile it, I have a syntax errors for those two operator function. For the Print() method, I have to use it for display the mantfacturere, model, year, total manufacture, total kilometers travelled and the amount of fuel costs, total number of services and fuel economy with print method. Can anyone please take a look at my code and help me fixing some of the mistakes in the header file?
Thank you PHP Code:
Last edited by Tozilla : March 26th, 2003 at 09:04 PM. |
|
#2
|
||||
|
||||
|
Re: Operator overloading,initization, Print() in header file
PHP Code:
PHP Code:
__________________
Jason Doucette / Xona.com™ - Programming Windows Errata Addendum "Discussion is an exchange of knowledge; argument is an exchange of ignorance." |
|
#3
|
|||
|
|||
|
You sure about that Jason Doucette?
|
|
#4
|
||||
|
||||
|
Re: Re: Operator overloading,initization, Print() in header file
You're right, I am wrong.
I thought he was using the class name and forgetting the scope resolution operator ::, which is only needed in the definition outside of the class. I didn't look at it carefully enough. The only thing wrong with his code is the const at the start. His code should be: Code:
Car operator +(const Journey& meter) const; Car operator +(const FuelPurchase& amount) const; |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Operator overloading,initization, Print() in header file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|