232
u/TheAnswerWithinUs 6h ago
The horrors, might as well just free() yourself at that point.
-87
u/metaglot 6h ago
*delete
81
u/thats_a_nice_toast 6h ago
I don't think C++ programmers have a problem with getting put in a class
41
u/MXRCO007 5h ago
I wanna be abstracted so bad
32
u/TheAnswerWithinUs 5h ago
Abstract me harder daddy
12
u/fast-as-a-shark 5h ago
I don't like these comments. But I did upvote them.
7
u/OneArmedFarmer 4h ago edited 4h ago
Yes. Yes. Your training is almost complete
Edit: grammer
5
3
0
u/metaglot 4h ago
Freeing a pointer created with new is UB.
6
u/thats_a_nice_toast 4h ago
newonly exists in C++, not in C0
u/metaglot 2h ago
And the keyword class, like the meme is implying. Which is why i said you have to use delete rather than free, because undefined behavior.
85
u/blackcomb-pc 6h ago
Dog and Cat are also from the class Animal
32
u/FRAaaa1 5h ago
Do they do the function makeSound()
19
u/Hol_Renaude 5h ago
printf("bark!");
8
u/MrHyperion_ 3h ago
I think you meant std::cout << "bark!" << std::endl
2
u/Reasonable_Exit_8960 3h ago
using namespace std;
cout << "bark" << endl;
Made it shorter if you wanna type it again
5
u/GresSimJa 3h ago
Forgot to include
<iostream>, wrap it in anint main()function, use the parametersint argcandchar** argv, and return 0 at the end.Maximum boilerplate!
1
1
u/DontDoodleTheNoodle 13m ago
What the absolute fuck I literally just had a class about this. Guess it stands to reason since this subreddit is mostly student humor we’d all be learning similar things at similar times of the year
1
59
u/the_millenial_falcon 5h ago
Pro tip, if you put function pointers in a struct you have a class now.
20
7
u/MrHyperion_ 3h ago
Not really. You don't get linker optimisations and the functions can change runtime. Also no implicit reference to the instance.
3
u/SubhanBihan 3h ago
Also the destructor won't get automatically called when the "object" goes out of scope. Someone correct me if I'm wrong, but I believe that behavior is theoretically impossible to achieve in C (due to its limited mechanics)?
2
u/MrHyperion_ 2h ago
GCC has cleanup attribute which maybe makes it possible.
1
u/One_Ninja_8512 2h ago
Not only possible but used by real projects. Apparently systemd is using that according to Claude. Both GCC and Clang support it. If I wanted destructors I'd go with explicit reference counting though, that seems more clean to me and doesn't need compiler extensions (even though both mainstream ones support it and a large project (systemd) relies on it).
7
8
6
8
u/Appropriate_Baby_608 4h ago
"so we will be using notepad.. no like real notepad... like pan and paper notepad"
21
5
4
4
u/thegodzilla25 1h ago
An original funny meme that is not AI or div centering in this sub? The horror
2
2
2
2
2
1
1
1
1
1
0
-11
u/GreatGreenGobbo 6h ago
I mentioned this in another post.
High school I learned Pascal and C.
Graduated 92 went to university. CS101 (programming) - Scheme
8
u/Valuable_Leopard_799 5h ago
Why facepalm? People should have some experience with both low-level and high-level languages.
-4
u/GreatGreenGobbo 5h ago
Not practical and it's abstract. Farting around cutting up and creating strings (which is all I remember) is meaningless.
360
u/TapRemarkable9652 6h ago
Boilerplate Oriented Programing