- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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. |
- Related Articles
- Difference between Structures in C and C++
- Differentiate between array and structures in C
- Difference between Stack and Queue Data Structures
- Difference between Linear and Non-linear Data Structures
- Structures in C
- Classes vs Structures in C#
- Inbuilt Data Structures in C#
- 2-3 Trees - Data Structures and Algorithms in C++
- What are nested structures in C language?
- Difference between Internal tables, structures or work areas in SAP ABAP
- Data objects and Structures
- Explain the array of structures in C language
- What are pointers to structures in C language?
- Explain structures using typedef keyword in C language
- C program to store inventory system using structures

Advertisements