Difference between class and structure in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Difference between class and structure in c++?

26th Nov 2017, 4:44 AM
Prasun Khanra
Prasun Khanra - avatar
3 Answers
+ 7
Key Difference: C++ is an object oriented language that mainly focuses on objects. A class in C++ can be defined as a collection of related variables and functions encapsulated in a single structure. Instances of the class are termed as objects. A structure in C++ can be referred to as an user defined data type possessing its own operations. Unlike in the C language, they both are quite similar in C++. The main difference that exists between them is regarding the access modifier; the members of a class are private by default, whereas members of a struct are public by default. 
26th Nov 2017, 4:51 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
yes datatyps ; if u use int in Class u need to use int only
26th Nov 2017, 4:49 AM
Sachin Lobo Jeppu
Sachin Lobo Jeppu - avatar
- 1
Ok here is your answer ☺️ Members of Class are by default private. But Members of structure are by default public. That is the simplest difference
26th Nov 2017, 4:46 AM
Vishesh