gpt4 book ai didi

c++ - 错误:没有匹配函数来调用...(std::string&)

转载 作者:搜寻专家 更新时间:2023-10-30 23:59:23 26 4
gpt4 key购买 nike

我收到以下编译器错误

error: no matching function for call to 'infxTree(std::string&)'

对于这段代码。

int main(){
string infxStr;

cout << "Enter an infix string: " << endl;
cin >> infxStr;


prefixOutput(infxTree(infxStr));
postorderOutput(infxTree(infxStr), ' ');
displayTree(infxTree(infxStr), infxStr.size());
return 0;

我在最后 3 行中得到了错误。这是函数:

template <typename T>
tnode<T> infxTree(const string& iexp);

知道我做错了什么吗?谢谢!

最佳答案

你必须明确地给出模板参数:

infxTree<Foo>(infxStr)

其中 Foo 是提供给模板化 tnode 类的类类型。

关于c++ - 错误:没有匹配函数来调用...(std::string&),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16630774/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com