130
The C++ experience (lemmy.world)
you are viewing a single comment's thread
view the rest of the comments
[-] MyNameIsRichard@lemmy.ml 4 points 1 week ago

The compiler will still generate one. It won't be any use but it will be generated :)

[-] Valmond@lemmy.world 1 points 1 week ago

Well no because if you allocate stuff in the constructor, you are going to write a destructor now, freeing that allocated stuff up / closing that socket, pipe whatever etc.

Right?

Right??

[-] MyNameIsRichard@lemmy.ml 4 points 1 week ago* (last edited 1 week ago)

If I do it straight after the constructor, then definitely but if I get distracted by something else then it's only probably until I run it through valgrind and see the leak. These days, I mostly use smart pointers in new code though so there are fewer opportunities to need a destructor. It's funny that I never forget when opening a file or db connection!

[-] Valmond@lemmy.world 1 points 1 week ago

After the constructor?

No need for a destructir bc smart pointers?

Man you does not make any sense.

[-] MyNameIsRichard@lemmy.ml 3 points 1 week ago

Man your reading comprehension is really low.

this post was submitted on 15 Nov 2024
130 points (97.8% liked)

Programmer Humor

19623 readers
1 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS