+ 12

What’s the difference between classes in cpp and structs in c language?

25th Mar 2020, 7:19 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
10 odpowiedzi
+ 24
Nika Soltani Tehrani A structure is used for handling a group of logically related data(only data) items. They do not permit data hiding and their members are public by default. Standard C doesn't allow struct data type to be treated like built-in type. Class is used to hold data and function both and by default members of class are private. This work as built-in DT.
25th Mar 2020, 7:50 PM
Vinesh Wadhwani
Vinesh Wadhwani - avatar
26th Mar 2020, 10:32 AM
Vinesh Wadhwani
Vinesh Wadhwani - avatar
+ 6
Such valuable information Vinesh Wadhwani🇮🇳 Thanks a lot🙏😊
25th Mar 2020, 8:48 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
+ 6
Thank you so much Saad Mughal for your help🙏
25th Mar 2020, 8:49 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
+ 4
Both have different too visit this site you can understood in better way https://www.google.com/amp/s/www.geeksforgeeks.org/difference-between-class-and-structure-in-c-sharp/amp/
26th Mar 2020, 4:47 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
 Structs are value type whereas Classes are reference type. Structs are stored on the stack whereas Classes are stored on the heap. ... Structs can not have explicit parameterless constructors whereas a class can structs doesn't support inheritance, but classes do.
27th Mar 2020, 12:47 PM
Zahid Zubair
Zahid Zubair - avatar
+ 2
In struct all of your data is public by default In classes all of your data is private by default
25th Mar 2020, 7:48 PM
Saad Saleem
Saad Saleem - avatar
+ 2
A few days ago I discussed with a friend if it was possible to do object-oriented programming only with structure and function pointers, I think the basics of the concept can be done, but the facilities that the classes have in terms of handling and permissions are a big difference.
27th Mar 2020, 5:32 AM
Blas
Blas - avatar
+ 1
In class, we have access specifiers to protect data from unknown persons and we can also add behavior to the objects using functions. struct data members will consume memory for each data type and it'll add the memory space of each data member. By default, the data members are public in structures. while in class, by default the data members are private which will protect the data from unknown persons and we can also use destructors to deallocate the data members to store the memory.
8th Oct 2020, 11:53 AM
Thimmareddygari Jagadeeswar Reddy
Thimmareddygari Jagadeeswar Reddy - avatar
25th Mar 2020, 8:51 PM
Saad Saleem
Saad Saleem - avatar