Question: Hi, I am trying to create a function to read the file and instantiate the questions one by one, adding them to the questions vector.

Hi, I am trying to create a function to read the file and instantiate the questions one by one, adding them to the questions vector. How can I add to my code and do this?

My file is questions.txt with contexts of:

206 How many bones are in the average adult human? 2000 How many yards are in a nautical mile? 195 How many countries are in the world? 15 How many hands high must an equine be to be considered a horse, instead of a pony?

Code reading file:

#include #include #include #include using namespace std; class QuestionBank {

public: void LoadQuestions(string fname) { ifstream questionsFile; questionsFile.open(fname); if (questionsFile.fail()) { cerr << "Can't open "; exit(-1); } } };

I am unsure how to create the vector to store the questions and answers...

i also need to create a function

getNextQuestion()

This function should return a question from the list for use by the Game class, described below.

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!