confused with some code

closed account (i8bjz8AR)
Can someone explain what this code does? I think i have an idea but not quite sure
1
2
3
4
  stringstream ss; //copys content into variable ss
                        ss<<typeid(a.elems[i]).name(); //referring to an index of a.elems.name(), which a for loop incremented(not including the for loop here)
                        string temp; //create a temporary variable to hold a data type of string
                        ss>>temp; //temp variable to hold ss data 
ss is a variable of type "std::stringstream". A stream object.

a is something that has an array-like member elems.
typeid is an operator that returns std::type_info object
http://en.cppreference.com/w/cpp/language/typeid

typeid from array element thus creates an std::type_info about the element.
The std::type_info has member function name() that returns const char *
http://en.cppreference.com/w/cpp/types/type_info/name

The C-string returned by name() is written to stream ss. (Just like std::cout << "hello"; does output.)

temp is a variable of type "std::string".

One word is read from stream ss and stored in variable temp. (Just like std::cin >> temp; does formatted input.)
closed account (i8bjz8AR)
okay thanks that makes sense!
Topic archived. No new replies allowed.