-3
我試圖使用模板作爲通用(它應該是)成員來保存我的菜單的GUI組件。我正在嘗試使用節點來創建一個菜單,並且我收到了C2244和C2955這兩個錯誤。我查看了這些錯誤,並將它們與我的代碼進行了比較,似乎無法找到我的問題。模板類中的返回節點
我沒有包含構造函數定義,因爲問題是編譯器錯誤。如果你是
編譯器錯誤懶得看的段落:
錯誤1:
Severity Code Description Project File Line Suppression State
Error C2244 'GUI::MenuNode<ui_Interface>::select': unable to match function
definition to an existing declaration
和
錯誤2:
Severity Code Description Project File Line Suppression State
Error C2955 j'GUI::MenuNode': use of class template requires template
argument list
template<class ui_Interface>
class MenuNode {
private:
shared_ptr<MenuNode> itself;
vector<shared_ptr<MenuNode>> nodes;
ui_Interface *u_Interface;
public:
//returns the address of the newly selected node
//itself if nothing is to be returned
const MenuNode& select();
//returns interface member
ui_Interface getInterface();
MenuNode();
~MenuNode();
};
template<class ui_Interface>
const MenuNode & MenuNode<ui_Interface>::select() { //Errors occur here
for (int i = 0; i < nodes.size(); i++) {
if (nodes[i]->getInterface().mouseSelect()) {
return *nodes[i];
}
}
return *itself;
}
任何錯誤的詳細信息? – edtheprogrammerguy
是的,他們在段落 –
你似乎懶得發表這些錯誤的文本,並指出他們在你的代碼中發生的地方。 –