I don’t necessarily disagree but anyone who is a c++ programmer and sees
class foo {
public:
foo() {
ptr = new other();
}
~foo() {
}
};
And doesn’t immediately question it doesn’t instil confidence.Interviews are inherently high pressure situations for the candidate, the only way to avoid that is to just let people try out on the job and fire them if it isn’t working out. That’s unfair to everyone.
Does this example even compile, given that ptr is not declared anywhere?
Forgive me, I'm a Java programmer.
The glaring bug here is that ptr is - or rather the object being pointed to is - on the heap and allocated in the constructor, but the deconstructor doesn't free it?