1. Engineering
  2. Computer Science
  3. can someone tell me why this code will not work...

Question: can someone tell me why this code will not work...

Question details

Can someone tell me why this code will not work? I am using two files.

One: main.cpp -- I am using this to ask for user input for a file name

two: questionbank.h -- a question class with a void function to load the questions LoadQustions where I try to load the file

Main.cpp :

#include<questionbank.h>
#include<iostream>
using namespace std;
int main(){
string inputFile;
cout << "Welcome to to wages\n";
cout << "Enter a filename: "; cin >> inputFile;
LoadQuestions(inputFile);

return 0;
}

questionbank.h:

#include <fstream>
#include <iostream>
class QuestionBank{
ifstream file;

void LoadQuestions(string fname){
      file.open(fname);
      if(file.fail()) {
      cerr << "Can't open\n"
      exit();
   }

}

/*void LoadQuestions(){


}

};

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution