Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Copy a Base Class to a Derived Class
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Vidar Hasfjord, post: 3760112"] Good. And, yes, you are finding the limits of C++. It doesn't buy you anything though. What you have created is a new object pointed to by 'd' that contains some copied parts of a Base object; a Frankenstein monster with undefined behaviour. You can make it come alive, but you have no guarantees from the C++ standard or the compiler. In fact, see Paul's reply for how you can safely and easily copy the base part to a new derived object. Neither solves the problem though. The essential point is that the original Base object; which in your problem statement is owned and handled by the untouchable library; is still unchanged and not associated with your additional data. For example, you cannot use this technique to pass along extra data in the handler example in my previous post. So your technique doesn't solve any problems; and worse; it is not reliable. Regards, Vidar Hasfjord [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Copy a Base Class to a Derived Class
Top