Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

2 What supply is and what affects it.

Answered: 1 week ago