我正在通过“加速C++”。我有一个关于问题5-3的问题。它要求:什么是驱动程序功能?
5-3. By using a typedef, we can write one version of the program that implements either a
vector-based solution or a list-based one. Write and test this version of the program.'
下一个问题问:
5-4. Look again at the driver functions you wrote in the previous exercise. Note that
it is possible to write a driver that differs only in the declaration of the type for the data structure
that holds the input file. If your vector and list test drivers differ in any other way, rewrite them
so that they differ only in this declaration.
到底是什么驱动程序的功能?我已经通过创建if语句以及重载函数来处理不同的数据类型,像这样解决5-3:
cout << "Please enter 1 if you would like to use vectors, or 2 if you would like to use lists: "<< endl;
int choose;
cin >> choose;
//CHOOSING TO USE VECTORS
if (choose == 1){....vector<Student_info> allStudents;
vector<Student_info> fail;.......}
//CHOOSING TO USE LISTS
else if (choose==2) {....list<Student_info> allStudents;
list<Student_info> fail;....}
//INVALID CHOICE
else {...invalid number, try again...}
我没有创造除了那些超载任何额外的功能来处理不同的数据类型。这些驱动程序功能?如果不是的话,我一定在做错了。有人可以点亮一些光线吗? :>
你可能想读这2005线程。 http://bytes.com/topic/c/answers/167496-accelerated-c-clarification-wording-exercises – KeithSmith
驱动程序的功能很可能被写入演示一些图书馆式的代码,解决问题的操作功能。例如,如果你编写了一些类'A',驱动程序函数就是代码中的函数,只是为了显示类“A”的行为如预期。所以,第一个驱动函数本身就是'main',然后是'main'中调用的任何其他函数,它们都是'A'类的客户端。 – LavaScornedOven
对于一本强烈推荐的书,写作往往是非常残酷的。互联网上有多个线程试图解析他们实际上在问什么问题。我一直试图从字面上重新编写问题,以便在没有互联网搜索的情况下理解它们。 (是的,这将是讽刺)这是否显示C++教学法的状态是多么令人遗憾,如果尽管它存在不可否认的缺陷,它仍然位列榜首。 – neuronet