|
-
July 1st, 2011, 06:52 AM
#16
Re: Stack/Queue Question
Well, there are cases where private inheritance is mandatory, compared to composition. Keeping in the mindset that private inheritance means "is implemented in terms of":
What if the object you are "implementing in terms of" can be customized by overiding a private virtual function?
What if you want your object to be "implemented in terms of" two different classes, both of which virtually derive from the same base class (the dreaded diamond)?
Now, we could argue that any application that does this might best be purged in fire along with all the hardware it has ever touched, but still. Private inheritance can give you more functionality than can be obtained through composition alone.
Composition is probably easier and safer, but just like the pointer vs reference idiom "References when you can, pointers when you must".
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|