Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why there is no virtual destructor in sfml game development book ?  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

shayan-sa

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Hi
i am reading sfml game development book and i am wondering about why there is no virtual destructor in the codes ? for example scene node is a base class that contain some virtual functions , then aircraft is an entity where entity is itself a scene node . we assign an aircraft to one the scene nodes as unique_ptr<sceneNode>.
so here delete is performed on the scene node ! now we don't have any virtual destructor in the scene node . also there is none in the entity class .
so only the default destructor of the scene node is called , and derived classes resources will leak .
i have read that there must be a virtual destructor , if and only if , there is a virtual function exists in the base class code .and in our case there is virtual function

that is what i think , any way if i am wrong please guide me .
thanks .
« Last Edit: May 19, 2016, 10:13:10 pm by shayan-sa »

shayan-sa

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
i was wrong . Scene node base classes are transformable , and drawable .
they both has virtual destructors . so , the scene node class has virtual destructor too , and all the derived classes in the hierarchy .

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Also there is a dedicated thread for this book here
http://en.sfml-dev.org/forums/index.php?topic=11992.0

 

anything