struct in class
If I remeber correctly there was a way to declare and use a struct in a class, where you fill the struct in another part of the program:
// some.h
class sample{
public:
struct HERE;
};
// main.cpp
#include some.h
...
struct HERE{
int x;
};
...
This was possible right? Can anyone give me an example please?
Try this:
Hope that helps.
John.
//some.hstruct Struct { int member1; int member2;};class Class { private: int member1; int member2; public: Struct classStruct; //rest of class};
//some.cppint main() { int variable; Class myclass //...later in the function myclass.classStruct.member1 = variable; //...rest of function}
Hope that helps.
John.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement