Hello Draveis,
Your dearth of code poses more questions than just what needs fixed.
zapshe has covered the problem with lines 20 and 28.
Without the rest of the code the questions are:
What is "Question"? Is this a class or a struct?
When you define the parameters of your functions. What is the point of "Question *myQuestions[]"? Is this a pointer, an array or an array of pointers? As is it does produce an error at compile time.
Where does "loopcounter" come from?
Is "Question" in a header file or in the file with "main"? If it is a separate file you need to include that in your post.
Without the rest of the code I have no way to answer these questions or come up with a way to get the program to compile or even test.
In the for loop of "addQuestion" did someone teach you the most difficult way of doing this or did you try to learn this from a book?
You are using "std::string"s. Use this to your advantage do not work against it.
You could do something like:
1 2 3 4 5
|
std::cout << "\n Enter the Question type followed by a comma then the question type and its point value"
<< "\n (Your question,T or F value): ";
std::getline(std::cin, theQuestion, ',');
std::cin >> quiztype >> questionvalue;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
|
This way you input direct to the variables without the need of using the "substr".
I would change "quizetype" to a char not a string. And when expecting input from the use you only need one letter. This will save you from having to check every possibility in the if condition.
While I am here
int npos = line.size();
. It does work, but not the best idea as there is
std::string::npos
and your redefinition, although a local variable to the for loop, is confusing.
Also
line.size()
it the total number of elements of the string. This could affect your calculation ending up one more than you need.
I do not know what you need for this program, but there is only so much that can be done with the code given.
Hope that helps,
Andy