Quick question:
Someone told me that it's not customary to use structs in c++,
is this true?
Quick question:
Someone told me that it's not customary to use structs in c++,
is this true?
C++ structs and classes have no difference except the visibility option....in struct default visibility mode is public whereas in classes its private....
"Service of the poor and destitutes is the service of the God"
Normative Changes to ISO/IEC 9899:1990 in Technical Corrigendum 1
Incompatibilities Between ISO C and ISO C++
so your saying that there is no reason to use structs in c++?
There probably isn't much need for you to use structs while writing new programs, but a lot of libraries / API's use them (win32 for example), so you will still use them at some point.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
Use whatevr you feel likeOriginally Posted by owi_just
"Service of the poor and destitutes is the service of the God"
Normative Changes to ISO/IEC 9899:1990 in Technical Corrigendum 1
Incompatibilities Between ISO C and ISO C++
I tend to use struct out of habit when I know I wont need any member functions.
Technically, there is no reason to use classes instead of structs in C++ code. They are the same thing, apart from default access specifiers.
structs are used to implement PoD (Plain old Data) types (which, broadly, means a struct type that would be understood by a C compiler: no user supplied constructors, destructors, member functions, private or protected attributes,...). PoD allow data structures to be passed to functions that are written in C.