Can classes be thought as structures in c? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can classes be thought as structures in c?

5th May 2020, 9:13 AM
Goudu Vimal Keerthi
Goudu Vimal Keerthi - avatar
2 Answers
+ 1
Avinesh You are right on first point... but second point is not. structures in C can have member functions as well. As an example: struct test { int x, y; int (*cmp)(void *a, void *b); void (*print)(int value); };
9th May 2020, 12:19 PM
Gen2oo
Gen2oo - avatar
0
Yes you can say that, one common difference is that all the structure members are by default public whereas all class members are by default private. Structures in C cannot have member functions whereas classes in C++ can.
5th May 2020, 10:56 AM
Avinesh
Avinesh - avatar