![]() |
|
#1
|
|||
|
|||
Overloaded operator + base / derived class questionHi, I have been learning about inheritance and then began to try some overloaded operators in them.
It was all making sense until I ran into something which I try to condense into the program below. In there you will see I have two "myteries" which I could use some help in understanding. CPP / C++ / C Code:
Code:
Any light ya'll could shed on those mysteries would be apprecianado. Thanks , Howard |
|||
|
#2
|
|||
|
|||
Re: overloaded operator + base / derived class questionCPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
Google "c++ slicing" or similar to find discussions. I don't know exactly in what cases this is a bad thing as long as you keep in mind for example the following: CPP / C++ / C Code:
It's also good habit to pass by reference in these cases, like this: CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: overloaded operator + base / derived class questionNice explainations, thanks.
Quote:
CPP / C++ / C Code:
At first I thought it might be that OLOP1 was being used and I put those little couts in each one to find out. Then I was suprised to see that it was OLOP3 that was being used. You explained how that is possible , but now I am curious why OLOP1 was not used? ( And then how it could be used at all from the derived class? ) But don't worry about it, I understand enough for now. I'll just keep rolling and gather some more moss. Thanks again, Howard |
|
#4
|
|||
|
|||
Re: overloaded operator + base / derived class questionQuote:
CPP / C++ / C Code:
CPP / C++ / C Code:
If anyone knows how it's "done right", please share. |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get a handle to a derived class? | Futterama | MS Visual C++ / MFC Forum | 1 | 29-Jan-2007 10:47 |
| Hard drive/CPU Diagnoses Issues | binarybug | Computer Hardware Forum | 1 | 22-Jan-2007 20:23 |
| Message Class | TransformedBG | C++ Forum | 5 | 29-Nov-2006 22:28 |
| a tester class and then some. | postage | Java Forum | 1 | 06-May-2006 16:48 |
| Opinion on my code and a c++ class question | FlipNode | C++ Forum | 7 | 07-Feb-2006 09:15 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The