Professional Documents
Culture Documents
Difference Between Class and Structure
Difference Between Class and Structure
In C++, a structure works the same way as a class, except for just two small differences. The most
important of them is hiding implementation details. A structure will by default not hide its
implementation details from whoever uses it in code, while a class by default hides all its implementation
details and will therefore by default prevent the programmer from accessing them. The following table
summarizes all of the fundamental differences.
Class Structure
1. Members of a class are private by default. 1. Members of a structure are public by default.
4. It is declared using the class keyword. 4. It is declared using the struct keyword.
6. NULL values are possible in Class. 6. NULL values are not possible.
7. Syntax: 7. Syntax:
}; };