我正在通過「加速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