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
- How to convert string to char array in C++?
- ld: symbol(s) not found for architecture x86_64 error
- C++ string to double conversion
- Is there a C++ decompiler?
- What is a dangling pointer?
- undefined reference to WinMain@16 (codeblocks)
- error: redefinition of class
- How to convert a std::string to const char* or char*
- Why doesn’t std::vector::push_front() exist?
- Fastest way to check if a file exist using standard C++/C++11,14,17/C?
- Convert a String In C++ To Upper Case
- Accessors and Mutators C++
- Error C1083: Cannot open include file: ‘stdafx.h’
- How to get current time in milliseconds?
- Resizing dynamic array in c++
- C++ – Nested include – Avoiding ‘include nested too deeply error’
- Undefined reference to a static member
- How to sort with a lambda?
- stoi function gives error: std::invalid_argument at memory location 0x0035E8D8. c++
- Unrecognizable template declaration/definition
- MSVCP120d.dll missing
- Modulo operator with negative values [duplicate]
- Why does my program give “NULL used in arithmetic”
- no matching function to call for “getline”