|
-
July 2nd, 2009, 03:46 AM
#1
Different return type depending on data
I'm designing a class where there's a method that should return a different data type depending on certain circunstances.
Specifically, I'm reading from a text file. If the data found are strings of characters, I'd like to return a vector of strings. On the other hand, I'd like to return a vector of floats if the data are numbers.
template <typename T>
vector<T> funcion(string typeConversion){
if (typeConversion== 'String')
//...
return list<string>
else if (typeConversion == 'Number')
//...
return vector<float>
}
I don't think this is possible with C++ (in Python, for instance, I think that methods can return every data type).
Do you know any alternative to solve my problem?
Thanks!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|