I'm going through someone else's code and came across the following syntax:
typedef struct abc {
abc() : member(0){}
unsigned int member
}
It seems like a class with member variable and a constructor, except it is declared struct. I have two questions here.
Thanks a lot in advance.
PS: how do I format the code?
This is not valid C.
In C++, struct and class are essentially synonyms. The only difference is that members and inheritance are public by default in a struct, and private by default in a class.
There are no hard guidelines on whether to choose struct or class. However, you'll often find people using struct only for simple C-like plain old data structures ("PODs").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With