Question about multiple type arrays
I'm using C++ (gcc) and want to know if there's a way to do something similar to what I can do in VB.NET:
dim arrData as Dictionary(typeof String, typeof Object)
In other words, it is a key/value pair array that you can just arrData.Add(key, value) and it adds it. I would be willing to even write such.
The thing is, the key is string (a name of the key) but the value can be of any type. It might be a string, a date, an int, long, double, who knows.
Is there a way in C++ to do this, have different types in an array? Or if not, then maybe I could put everything as string and have a 3rd parameter like:
arrData.Add(key, value, value_type);
Where the key, value and value_type are all strings but the value_type would denote what the type of the value should be, and then one can convert it?
Or is there a better way?
Last edited by FuzzieDice; 02-27-2007 at 01:33 AM.
|