What the difference between structure and class ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What the difference between structure and class ?

27th Aug 2017, 4:58 AM
Nitesh
Nitesh - avatar
4 Answers
27th Aug 2017, 5:01 AM
Hatsy Rei
Hatsy Rei - avatar
+ 9
In addition to dear hatsi's post, I'd like to point out to another area that class has advantage over struct. I fetched this one from StackOverflow. You can't use a struct as a template's parameter. For example, template < class T > .... is allowed template < struct T > ..... is not
27th Aug 2017, 6:04 AM
Babak
Babak - avatar
+ 3
structure is not an OOPs concept but class is an OOPs concept
27th Aug 2017, 5:18 AM
subham sahu
subham sahu - avatar
+ 1
Member's of class are are private by default while struct members are public by default. When deriving a struct from a class/struct, default access-specifier for a base class/struct is public. And when deriving a class, default access specifier is private.
27th Aug 2017, 1:40 PM
Amit Singh
Amit Singh - avatar