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
Post a Comment