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

Programmer Humor

19564 readers
635 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
 
top 11 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 30 minutes ago
[–] [email protected] 12 points 15 hours ago

0 3 * * * reboot

[–] [email protected] 8 points 16 hours ago (1 children)

There's always a destructor though. It may do nothing but it's there.

[–] [email protected] 8 points 15 hours ago (1 children)

No need to declare it though ofc.

Rule of 0/3/5

[–] [email protected] 3 points 14 hours ago (1 children)

Yeah the compiler generates it so it's always there

[–] [email protected] 2 points 13 hours ago (1 children)

Well yes, except when you allocate stuff in the constructor.

[–] [email protected] 1 points 3 hours ago (1 children)

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

[–] [email protected] 0 points 3 hours ago (1 children)

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??

[–] [email protected] 2 points 2 hours ago* (last edited 2 hours ago) (1 children)

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!

[–] [email protected] 1 points 22 minutes ago (1 children)

After the constructor?

No need for a destructir bc smart pointers?

Man you does not make any sense.

[–] [email protected] 1 points 4 minutes ago

Man your reading comprehension is really low.