Home » Community » Newbie corner » |SOLVED] Vector of object: cast to inherited class
Re: |SOLVED] Vector of object: cast to inherited class [message #52377 is a reply to message #52353] |
Mon, 16 September 2019 09:35   |
 |
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello Novo,
Quote:Why the code below is working the way it is working (printing out "Hello from A" instead of "Hello from B")? Smile
That's because we didn't define any destructor on B.
Edit : I just tried to define B destructor and A destructor is still called after B destructor call.
That's not the behaviour I would have imagined but it's quite logique.
Quote:A hint: I'm not using a keyword class. I'm using struct instead. This makes code shorter and cleaner.
Also Except Struct is well aligned in memory and you didn't set accessor flag to public, what's the difference between class and struct ?
Thanks in advance.
[Updated on: Mon, 16 September 2019 10:43] Report message to a moderator
|
|
|
 |
|
|SOLVED] Vector of object: cast to inherited class
By: Xemuth on Fri, 13 September 2019 16:32
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Fri, 13 September 2019 21:55
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sat, 14 September 2019 00:29
|
 |
|
Re: Vector of object: cast to inherited class
By: Xemuth on Sat, 14 September 2019 13:41
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sat, 14 September 2019 21:39
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sat, 14 September 2019 21:45
|
 |
|
Re: Vector of object: cast to inherited class
By: Xemuth on Sun, 15 September 2019 12:52
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sun, 15 September 2019 17:31
|
 |
|
Re: Vector of object: cast to inherited class
By: Novo on Sun, 15 September 2019 17:54
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 09:35
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 16:29
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 16:31
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 16:47
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 17:44
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 20:02
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 20:09
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Mon, 16 September 2019 20:25
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Novo on Mon, 16 September 2019 23:47
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Tue, 17 September 2019 09:55
|
 |
|
Re: |SOLVED] Vector of object: cast to inherited class
By: Xemuth on Tue, 17 September 2019 14:11
|
Goto Forum:
Current Time: Sun Aug 24 19:21:08 CEST 2025
Total time taken to generate the page: 0.05014 seconds
|