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

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -