|
Answer» The DIFFERENCES between struct in C++ and C are listed in the following points:
- In C and C++, the variables of the structures are public; however, in C, the variable cannot be declared as private or protected. On the contrary, in C++, the variables can be declared as private or protected.
- On declaring a struct in C, the ADDITION of the struct keyword is must. On the contrary, there is no need of the struct keyword on declaring struct in C++.
- In C, structures do not have direct functions or methods (procedures). Example, pointers INSIDE the functions. On the other hand, C++ has direct functions or methods, for example CLASSES.
- In C, the INITIALIZATION cannot be done outside the scope of a structure. However, in C++, the initialization can be done outside the scope of a structure.
- In C, the concept of inheritance is not supported. In C++, the concept of inheritance is fully supported.
The differences between struct in C++ and C are listed in the following points:
|