Hacker News new | past | comments | ask | show | jobs | submit login

The C++ experts here will be able to confirm, but if my memory serves, I think the story about virtual destructors doesn't make sense:

> Specifically, the class had a virtual destructor, but the derived class failed to declare its own destructor as virtual.

The derived class doesn't have to declare its destructor as virtual. What matters is that the base class does so.

> This led to undefined behavior when deleting objects of the derived class, which in turn caused the program to crash.

No; the undefined-behavior case arises if the base class destructor is not declared as virtual, and you then try to delete a derived class via a pointer-to-base.[1]

So this is a nice example of ChatGPT producing something that looks plausible, yet on examination, betrays the fact that it has no actual "understanding" of the topic.

[1] https://en.cppreference.com/w/cpp/language/destructor




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: