You forget the tricky 2nd difference between classes and structs.
Quoth the standard (§11.2.2 in C++98 through C++11):
In absence of an access-specifier for a base class, public is assumed when the derived class is declared struct and private is assumed when the class is declared class.
And just for completeness’ sake, the more widely known difference between class and struct is defined in (11.2):
Member of a class defined with the keyword class are private by default. Members of a class defined with the keywords struct or union are public by default.
Additional difference: the keyword class
can be used to declare template parameters, while the struct
keyword cannot be so used.
Related Posts:
- When should you use a class vs a struct in C++?
- Why is enum class preferred over plain enum?
- Separating class code into a header and cpp file
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- Struct with template variables in C++
- Error: invalid use of member in static member function
- What are the differences between a pointer variable and a reference variable in C++?
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- Why is “using namespace std;” considered bad practice?
- What is a lambda expression in C++11?
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- What does the explicit keyword mean?
- Expression must have class type
- Struct Constructor in C++?
- C++ struct constructor
- What is a smart pointer and when should I use one?
- What is the difference between private and protected members of C++ classes?
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- What does the explicit keyword mean?
- Reading from file in c++ ifstream
- Why am I getting this redefinition of class error?
- Single class has a Class Redefinition Error
- C++ Linked List Node with class
- (->) arrow operator and (.) dot operator , class pointer
- What is the difference between const int*, const int * const, and int const *?
- What does T&& (double ampersand) mean in C++11?
- What is the difference between const int*, const int * const, and int const *?
- how to define -std=c++11 as default in g++
- Pointer to incomplete class type is not allowed
- Why am I getting this redefinition of class error?
- What is move semantics?
- no default constructor exists for class
- Vector of structs initialization
- Error at constructor : Expected an identifier?
- error: expected primary-expression before ‘)’ token (C)
- Is the practice of returning a C++ reference variable evil?
- How to write C++ getters and setters
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- C++ BlackJack Stuck trying to program Ace
- What is std::move(), and when should it be used?
- error C2011: ” : ‘class’ type redefinition
- gcc/g++: “No such file or directory”
- Resolve build errors due to circular dependency amongst classes
- The compiler is complaining about my default parameters?
- C++ Expression must have pointer-to-object type
- Already defined in .obj – no double inclusions
- C++ Linked List Node with class
- Getting error: ISO C++ forbids declaration of with no type
- fatal error LNK1169: one or more multiply defined symbols found in game programming
- How to call a parent class function from derived class function?
- “used without template parameters”
- Difference between ‘struct’ and ‘typedef struct’ in C++?
- std::wstring VS std::string
- expected constructor, destructor, or type conversion before ‘(’ token
- C++ Class ‘undeclared identifier”
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- error: expected unqualified-id before ‘.’ token //(struct)
- Base class undefined
- What is object slicing?
- Function for C++ struct
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- What is the meaning of a C++ Wrapper Class?
- Does C++11 have C#-style properties?
- G++ undefined reference to class::function
- How to return a struct from a function in C++?
- Creating an instance of class
- Why should I use a pointer rather than the object itself?
- too many initializers for ‘int [0]’ c++
- expected primary-expression before ‘]’ token
- Struct inheritance in C++
- When/why to make function private in class?
- error C2039: ‘string’ : is not a member of ‘std’, header file problem
- istream and ostream problem – C++
- error: no member function declared in class
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- C++ equivalent of java’s instanceof
- Is “delete this” allowed in C++?
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- How to create a dynamic array of integers
- How to create a dynamic array of integers
- Linker Error C++ “undefined reference ” [duplicate]
- How do I build a graphical user interface in C++? [closed]
- C++ convert from 1 char to string?
- How do I build a graphical user interface in C++? [closed]
- convert a char* to std::string
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- What is the purpose of the word ‘self’?
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- How to implement 2D vector array?
- Why the switch statement cannot be applied on strings?
- What is the difference between g++ and gcc?
- How to use setprecision in C++
- How to dynamically allocate arrays in C++
- What does (~0L) mean?
- How to dynamically allocate arrays in C++
- What is the best way to use a HashMap in C++?
- Understanding Python super() with __init__() methods [duplicate]