Class vs Struct difference ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Class vs Struct difference ?

Is there any significant change in space/time difference between both the methods ?

31st Mar 2017, 2:36 AM
Shivansh
Shivansh - avatar
5 Answers
+ 16
31st Mar 2017, 2:52 AM
Hatsy Rei
Hatsy Rei - avatar
+ 10
Only difference is that structs have public members by default.
31st Mar 2017, 2:40 AM
Karl T.
Karl T. - avatar
+ 8
@Kinshuk .I think you're confusing C# with C++. Why do we use reference (&) then to pass objects?
31st Mar 2017, 3:22 AM
Karl T.
Karl T. - avatar
+ 4
@Helioform I read that here few weeks ago : www.differencebetween.info/difference-between-class-and-structure-in-cplusplus I thought that was what they meant by 'type' ... Maybe they meant something else...
31st Mar 2017, 4:18 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 3
Another difference is that data in classes is passed by reference , while it is passed by value in structures by default...
31st Mar 2017, 3:13 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar