logoalt Hacker News

fake-namelast Sunday at 5:54 PM2 repliesview on HN

- ptr isn't declared in the class body

- ptr is not being deallocated in the destructor

(personal preference - use of class member without explicit `this->`)


Replies

rightbytelast Monday at 10:28 AM

> "ptr isn't declared in the class body"

I would assume the interviewer messed up and forgot to declare it and if I just not pretend to assume it was "left out for brevity" I would fail the interview as a smart ass.

There are so many layers to interviewing and you kinda need to guess what the intervoewer wants to hear.

show 1 reply
setrlast Monday at 1:04 AM

If ptr is some kind of global, then it makes sense for it not to be deallocated by the destructor? It’s apparently not really managed by this class, so why would its lifetime be tied to it?

I mean it’s psychotic to half-manage it like this but I don’t think the lack of a destructor is suspicious here; in fact I think it’s correct once the global pointer was introduced

show 1 reply