cout << "How many questions are there going to be on this exam?" << endl;
cout << ">>";
getline(cin, totalquestions);
这段小代码来自我创建的一个类中的一个函数,我需要totalquestions
成为一个 int 以便它可以通过 for 循环运行并不断询问我提出的所有问题。
question q;
for(int i = 0; i < totalquestions; i++)
{
q.inputdata();
questions.push_back(q);
}
这段代码在哪里发挥作用?有没有人有任何想法来完成这项工作?