Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Sepplesox

Name: Anonymous 2011-07-24 21:05

Just tell me one thing about Sepplesox:  Can I have a container1 of mixed types2,3?  If the answer is no, then you can keep it and I'll stick with C, thank you.
1 vector, etc, not something custom
2 not a "vector of pointers," but a vector of actual objects of different classes
3 it's fine if the types are required to share the same base class, e.g. vector<shape> shapes = { circle, square, triangle };

Name: Anonymous 2011-08-08 15:29

>>1
Yes. C++11 has a std::tuple template class.

struct foo { int a; } a = { 0 };
int b = 1;
float c = 4.4f;

auto t = std::make_tuple(a, b, c); // type of t is std::tuple<foo, int, float>
std::cout << std::get(t, 1) << std::endl; // prints '1'

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List