350
you are viewing a single comment's thread
view the rest of the comments
[-] Gladaed@feddit.org 18 points 3 months ago* (last edited 3 months ago)

Because stuff can own other stuff and be owned at the same time. Also, arcane jackarsery.

Edit: if you want to give a function a pointer that it may change this may occur in a constructive way. I.e. replace an owned object.

[-] marcos@lemmy.world 5 points 3 months ago

Yeah... But it's usually a good practice to put a struct somewhere between your 30 levels of ownership.

Exceptions exist, but they are not very common. Also, in C++, operators overloading may help you if you keep needing to write code like this.

[-] Gladaed@feddit.org 3 points 3 months ago

In C++ you should never have owning raw pointers. Unless you have a good reason™.

Raw pointers are great, but not for ownership.

[-] qaz@lemmy.world 6 points 3 months ago* (last edited 3 months ago)

I just use unique_ptr 99% of the time

[-] Gladaed@feddit.org 4 points 3 months ago

And you should.

It even works for classes whose constructors your implementation cannot see, if you aren't a bitch about it.

this post was submitted on 29 Dec 2024
350 points (98.9% liked)

Programmer Humor

22134 readers
1925 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 2 years ago
MODERATORS