Class vs Struct | C++ (What's the Difference?)

  Рет қаралды 13,644

Caleb Curry

Caleb Curry

Күн бұрын

Пікірлер: 13
@codebreakthrough
@codebreakthrough Жыл бұрын
Are there differences I forgot? Be notified of new C/C++ course: calcur.tech/c-cpp-newsletter 💯 FREE Courses (100+ hours) - calcur.tech/all-in-ones
@AlexanderWeurding
@AlexanderWeurding Жыл бұрын
In C++, both classes and structs are used to define custom data types, and they share many similarities. However, there are a few key differences between them: Default member access: The default access level for members in a struct is "public", while the default for a class is "private". This means that members of a struct can be accessed directly from outside the struct, while members of a class cannot. Inheritance: A class can be inherited from another class or struct using the "class" keyword, while a struct can only be inherited from another struct. Member functions: A class can have member functions, which are functions that operate on the data members of the class. A struct can also have member functions, but they are not as commonly used. Constructors and destructors: A class can have constructors and destructors, which are special member functions that are called when an object is created or destroyed. A struct can also have constructors and destructors, but they are not as commonly used. In general, classes are used for more complex data types that require encapsulation and data abstraction, while structs are used for simpler data types that do not require as much abstraction or encapsulation. However, the choice between using a class or a struct ultimately depends on the specific needs of the program and the personal preferences of the programmer.
@pw.70
@pw.70 Жыл бұрын
'Preference of the programmer' - wow! Now there's a grey area!
@frankhart2188
@frankhart2188 Жыл бұрын
You forgot polymorphism i guess ;)
@uraymeiviar
@uraymeiviar Жыл бұрын
there are no difference, except the mistake that c++ allow struct to have similarr feature as class, they should keep struct as POD
@JimRohn-u8c
@JimRohn-u8c Жыл бұрын
Can you please make a beginner to advanced course on Go, because I still don’t understand, if you don’t use OOP in Go what do you use? I’m still a noob so don’t know everything. I’m used to Classes in Python.
@paullawrence7275
@paullawrence7275 3 ай бұрын
I have a question... Are instances of a struct, value types and not reference types? Thanks!
@dastin7276
@dastin7276 8 ай бұрын
Thank You. You are an excellent teacher.
@PandaXpress668
@PandaXpress668 Жыл бұрын
What vscode theme is that?
@ghsewar989
@ghsewar989 7 ай бұрын
Thank you so much!
@pw.70
@pw.70 Жыл бұрын
Isn't the primary difference by implication? Shouldn't programmers work to make structs immutable? I know this is the case with some other languages. Forgive me if I'm wrong, but I'm not a C++ developer.
@Fs-bc5fg
@Fs-bc5fg Жыл бұрын
Amazing, thanks
@micahjacobson8533
@micahjacobson8533 Жыл бұрын
Why is Child able to access a without making Parent public but Grandchild can’t?
Smart Pointers in C++ (Stop Using new?)
17:18
Caleb Curry
Рет қаралды 14 М.
CLASSES vs STRUCTS in C++
8:32
The Cherno
Рет қаралды 480 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
Structs in C | What you Need to Know
24:39
Caleb Curry
Рет қаралды 11 М.
Learning C++? Avoid these Beginner Mistakes...
13:47
Caleb Curry
Рет қаралды 6 М.
ECDSA Signatures | How does ECDSA work and what are Elliptic Curves?
10:10
Ciara Nightingale
Рет қаралды 2,1 М.
how Google writes gorgeous C++
7:40
Low Level
Рет қаралды 972 М.
you will never ask about pointers again after watching this video
8:03
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 839 М.
What is the Difference Between a Pointer and a Reference C++
7:58
Paul Programming
Рет қаралды 442 М.
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Рет қаралды 1,3 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН