我有這樣的代碼:沒有匹配函數調用
class XMLNode
{
//...
template <typename T>
bool getValue(T& t, const std::string& path) const
{
if (empty())
{
throw std::runtime_error("Empty node");
}
return nsXML::getValue(t, path, *node);
}
template <typename T>
T getValue(const std::string& path) const
{
if (empty())
{
throw std::runtime_error("Empty node");
}
return nsXML::getValue<T>(path, *node);
}
//...
};
class XMLData
{
//...
template <typename T>
T getValue(const std::string& path)
{
return XMLNode(&mDocNode, 0).getValue(path); // ERROR LINE
}
//...
};
,給我錯誤
no matching function for call to ‘nsXML::XMLNode::getValue(const string&)’
note: candidates are:
note: template<class T> bool nsXML::XMLNode::getValue(T&, const string&) const
note: template<class T> T nsXML::XMLNode::getValue(const string&) const
爲什麼g++
給我這個錯誤?
你需要傳遞一些模板參數該成員函數調用:'的XMLNode(mDocNode, 0).getValue(path);' –
juanchopanza