Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Nishtha Thakur

Here we will see what are the differences between structures in C and structures in C++. The C++ structures are mostly like classes in C++. In C structure, all members are public, but in C++, they are private in default. Some other differences are listed below.

C StructureC++ Structure
Structures in C, cannot have member functions inside structures.Structures in C++ can hold member functions with member variables.
We cannot initialize the structure data directly in C.We can directly initialize structure data in C++.
In C, we have to write ‘struct’ keyword to declare structure type variables.In C++, we do not need to use ‘struct’ keyword for declaring variables.
C structures cannot have static members.C++ structures can have static members.
The sizeof operator will generate 0 for empty structure in CThe sizeof operator will generate 1 for empty structure in C++
The data hiding feature is not available in C structures.The data hiding feature is present in C++ structures.
C structures does not have access modifiers.C++ structures have access specifiers.

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.