1.

How Can A Struct In C++ Differs From A Struct In C?

Answer»

The DIFFERENCES between struct in C++ and C are listed in the following points:

  1.  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.
  2. 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++.
  3.  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.
  4.  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.
  5.  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:



Discussion

No Comment Found