Define a struct inside a class in C++
Something like this:
class Class {
// visibility will default to private unless you specify it
struct Struct {
//specify members here;
};
};
declare class & nested struct probably in some header file
class C {
// struct will be private without `public:` keyword
struct S {
// members will be public without `private:` keyword
int sa;
void func();
};
void func(S s);
};
if you want to separate the implementation/definition, maybe in some CPP file
void C::func(S s) {
// implementation here
}
void C::S::func() { // <= note that you need the `full path` to the function
// implementation here
}
if you want to inline the implementation, other answers will do fine.