U++ framework
Do not panic. Ask here before giving up.

Home » Community » Newbie corner » |SOLVED] Vector of object: cast to inherited class
Re: |SOLVED] Vector of object: cast to inherited class [message #52383 is a reply to message #52382] Mon, 16 September 2019 16:47 Go to previous messageGo to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Novo wrote on Mon, 16 September 2019 16:31
Xemuth wrote on Mon, 16 September 2019 03:35

Quote:
Why the code below is working the way it is working (printing out "Hello from A" instead of "Hello from B")?


That's because we didn't define any destructor on B.

This is not a correct answer.


Since B inherite from A, B will call A's destructor right after exection of is own destructor.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: copying code from web into IDE
Next Topic: Simple way to develope 2D Game
Goto Forum:
  


Current Time: Mon Jun 15 08:40:56 GMT+2 2026

Total time taken to generate the page: 0.00671 seconds