Question: This is a c++ question. I am given a txt file with key value pairs. For example, each line will read something like cat 5000

This is a c++ question. I am given a txt file with key value pairs. For example, each line will read something like "cat 5000" or "dog 199" (without quotes). There are several lines with values like this. How can I read in these string and number values into a vector if, for example, I am given the code below to make the "sortData" function work?

class sortData

{

public:

//Required function to read file, make dictionary with values

sortData(string filename.txt);

private:

//class to store a string and number value.

class Data

{

public:

string s;

int number;

};

};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!