Anonymous
mostly
Anonymous
but i personally dislike it
Anonymous
i ensure other ways not to do it with unique pointer
Anonymous
by writting a free call anytime i allocate something
Anonymous
and also setting segmentation fault things
Anonymous
yes, do it! :)
but not as a member of a class!
Anonymous
we have to use them quite often in robotics as outside of a class
Anonymous
members should have the lifetime of the class
Anonymous
members should have the lifetime of the class
GCC sometimes fails to call destructors
olli
GCC sometimes fails to call destructors
example? file a bug report then
Anonymous
especially when it comes to virtual inheritance
Anonymous
example? file a bug report then
no need it is too minute a case to file an actual bug report
Anonymous
happened like 3 times for me
olli
It's so easy to make claims.. and so hard to prove them
Anonymous
but 2 of those i was trying to abuse my computer
BinaryByter
BinaryByter
it has never done so to me
BinaryByter
though GCC is kinda shit when it comes to kernel dev ;_;
olli
probably no virtual destructor
Anonymous
https://www.quantstart.com/articles/C-Virtual-Destructors-How-to-Avoid-Memory-Leaks
Anonymous
and also setting segmentation fault things
those errors drove me crazy when i was coding for a contest
Anonymous
probably no virtual destructor
that was the one time i legitamently had it
Anonymous
the other times was me purposefully causing these memory leaks
Anonymous
to see if i can use that code
Anonymous
Anonymous
like my last code i sent in this group
Anonymous
i get bored some times and make some codes
Anonymous
to test how far GCC can go
Anonymous
there would be better options!
BinaryByter
olli
like my last code i sent in this group
Would not pass my code review...
Anonymous
Would not pass my code review...
ya i am just playing around with those code
Anonymous
i do not push those to github
Anonymous
but sometimes i show the other devs and ask them to figure out what it says
Anonymous
without running the code
Anonymous
why?
Anonymous
why?
why? because it is a nice challenge
Anonymous
tests if you really know C/C++
BinaryByter
you require them however
do you know what a virtual class is?
BinaryByter
yes
rethorical question, you don't
Anonymous
Now, xD
BinaryByter
else you wouldn't instantiate it
BinaryByter
else you wouldn't instantiate it
also, you wouldn't expect a virtual destructor to do anything
Anonymous
searched it, it says 'nested class', do you call them virtual?
BinaryByter
what is that?
a class that CANNOT be instantiated but can be inherited from.
Anonymous
else you wouldn't instantiate it
you do not however the thing is you require a virtual destructor overload in order for a derived class to be able to call it's own destructor
Anonymous
that is the issue that is happening
olli
then that's an abstract class?
abstract / interface in C# / Java is "pure virtual" in C++
Anonymous
or interface
Anonymous
abstract / interface in C# / Java is "pure virtual" in C++
yep, a class WITH PURE virtual member functions
Anonymous
every class has its own destructor
however derived destructor is not called if the base constructor is not given a virtual overload
BinaryByter
every class has its own destructor
if you use the inherited constructor/destructor you can do so with the using directive. that is equivalent to shooting yourself in the foot though
Anonymous
but OOP has a same language anyway
BinaryByter
yep, a class WITH PURE virtual member functions
if one function is virtual the entire class is virutal
Anonymous
it is
nope i had this bug myself
Anonymous
and was trying to figure out why it was not working
BinaryByter
it is
@ollirz clear up my doubt
Anonymous
took us 1 day to figure it out
Anonymous
olli
You need the destructor to be explictely declared as virtual to make sure the most derived destructor is also called
Anonymous
https://stackoverflow.com/questions/25220229/in-c-inheritance-derived-class-destructor-not-called-when-pointer-object-to-b
Anonymous
see
Anonymous
which in my opinion is a bug