Differences between Structures in C and Structures in C++

Following are the differences between Structures in C and Structures in C++ :
  1. Structures in C cannot have Direct functions/methods inside a structure definition[But it still can have methods in the form of function pointers]. While structures in C++ can have functions/methods inside a structure definition.
  2. In C, an object(variable) of a structure is created using the keyword struct(otherwise syntax error). For example struct student sid; Whereas in C++ the struct keyword can be omitted while creating structure variables(objects). For example: student sid;
  3. C structures does not permit Data hiding concept whereas C++ structures allow Data hiding.

0 comments:

Post a Comment