當試圖建立一個包含下面的代碼C++程序:C++的構造函數調用另一個構造
menutype::menutype(int cat_num){
extras list = extras(cat_num);
}
extras::extras(int num_cats){
head = new category_node;
head->next = NULL;
head->category = 1;
category_node * temp;
for(int i = 1; i < (num_cats); ++i){
temp = new category_node;
temp->next = head->next;
head->next = temp;
temp->category = (num_cats-(i-1));
}
}
我收到的錯誤:
cs163hw1.cpp: In constructor ‘menutype::menutype(int)’:
cs163hw1.cpp:59:31: error: no matching function for call to ‘extras::extras()’
cs163hw1.cpp:59:31: note: candidates are:
cs163hw1.cpp:5:1: note: extras::extras(int)
而且我不明白爲什麼,請大家幫忙!
就是這樣,謝謝 – Flexo1515
@ user1404053隨時隨地。 –