I have a sample file where a line looks like this: CAR;FORD;FIESTA;WHITE;20300;19900;23555
Now i need to parse this line where first four attributes should be stored separately and for last three(or more) an average needs to be calculated ("choosing the right approach" in progress...)
When I successfully tokenize this I need to pass these tokens to a class that has a separate (public)variable for each attribute
class ClassA{ //aggregate class
public:
string vehicle;
string brand;
string model;
string color;
double avgPrice;
//...
};
What is the most appropriate approach?
When tokenizing, should I store all tokens in an array and then pass the array as parameter and then add a initialization lists to a
ClassAconstructor where i assign each correspondingArr[n]to an attribute?Or should I rather make a temp variable for each attribute and then do the standard initialization list. But this would make awful clumsy code, where i'd have to repeat the same thing 4 times each time storing a token in a different variable.
Feel free to offer an even better solution, for i am mere beginner in C++ and my knowledge of it's capabilities is basic.
Class A?