Looking at this portion:
Code:
c.push_back(IntStr(123, "abc"));
cout << c.at(0) << endl;
Is there any way to extract IntStr's individual parameters?
For example:
(I'm going to use faulty notation here, but it will look familiar enough to understand its logic):
Code:
c.push_back(IntStr(123, "abc"));
cout << c.at(0)[0] << endl;
cout << c.at(0)[1] << endl;
Result:
123
abc
Is it possible to have a vector of multiple datatypes?
This method would be messy, but if the above is possible, this vector could be made doing
Code:
c.push_back(IntStr(123, ""));
c.push_back(IntStr(0, "String1"));
c.push_back(IntStr(0, "String2"));
c.push_back(IntStr(456, ""));
cout << c.at(0)[0] << endl; //accessing integer portion of first element
cout << c.at(1)[1] << endl; //accessing string portion of second element
cout << c.at(2)[1] << endl; //accessing string portion of third element
cout << c.at(3)[0] << endl; //accessing integer portion of fourth element
using 0 and "" as default values.
The downside to this method is the wasted space these default values are using up. Still, a working version is better than no version. Until I can find some better method, this should do.
I guess the other method would be to make a vector of strings and convert the elements to int, float, etc.
when needed.