Is it possible to have a std::list as a member of a structure in C++? -


i'll describe question using example. have structure triangle:

struct triangle { int perimeter; double area; list <mystruct> sides; }; 

where mystruct is:

struct mystruct { int length; } 

is possible? there problems may appear?

yes, it's possible. in fact it's composition. can use this:

mystruct s; s.length = 10;  triangle t; t.sides.push_back(s); 

object composition way combine simple objects or data types more complex ones.


Comments

Popular posts from this blog

Pull out data related to my apps from Android Play Store and iOS App Store -

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -