|
-
July 3rd, 2009, 02:08 AM
#6
Re: Different return type depending on data
Thank you all for all your interesting and helping answers!
I'll explain more in detail what I'm trying to do:
I'm reading a text file that includes loads of data ordered by columns. Each column contains a different kind of data (it can be text or numbers). My method should return a vector (or any other data structure) containing the data from the column provided.
Depending on what kind of data the column has, I'd return a vector<string> or vector<float>, for instance.
vector<T> method(string column_name){
ReadColumnFromFile()
if Column is text
return vector<string>
else if Colum is numbers
return vector<float>
}
I think VARIANT it's a good option for solving that.
Another problem is to know when the information should be a string or a number (float, for example). When I read from the file I always get a string. I thought about using atof() to convert the string to a float; if it works it'll be a number, if not it'll be a string. What do you think?
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
|