Can we describe functions in a struct? For example, is this code valid?
struct function { int func() { return 5; } };
Yes, the only differences between a struct and class in C++ are:
struct
class
In C++, a structure is a class defined with the struct keyword. Its members and base classes are public by default. A class defined with the class keyword has private members and base classes by default. This is the only difference between structs and classes in C++.
2.1m questions
2.1m answers
60 comments
57.0k users