
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between C Structures and C++ Structures
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 Structure | C++ 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 C | The 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