C++ 未定义对带有队列参数的函数的引用

标签 c++ function parameters reference undefined

<分区>

我创建了一个标记化和字符串输入的类。它将字符串的组件转换为字符串队列,如下所示:

queue<string> Fraction::Tokenize( const string & infixExpression )
{
    queue<string> tokens;
    string currentToken;

    for( char currentChar : infixExpression )
    {
       currentToken += currentChar;
    }

    tokens.push(currentToken);
    return tokens;
}

这是将队列作为参数的函数:

Fraction evaluateInfix( queue<string> & infixQueue )
{
//code goes here
}

但是,当我从构造函数中调用这些函数时:

Fraction::Fraction( const string &infix )
{
    queue<string> myQueue = Tokenize(infix);
    *this = evaluateInfix(myQueue);
}

我收到以下错误:

Fraction.cpp:(.text+0x1fd): 未定义对`Fraction::evaluateInfix(std::queue < std::string, std::deque < std::string, std::allocator < std: :string >> > &)'

我这辈子都弄不明白为什么。感谢您的帮助。

最佳答案

您的成员函数定义缺少类的作用域:

Fraction Fraction::evaluateInfix( queue<string> & infixQueue )
         ^^^^^^^^^^

关于C++ 未定义对带有队列参数的函数的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24600714/

相关文章:

javascript - javascript函数中的所有语句都没有被执行

c - argv 的双指针

javascript - servlet 问题中无法检索 Ajax 请求参数

c++ - new[]和delete不匹配,为什么没有内存泄漏?

c++ - Visual Studio 2013 Update 2 中的 C++ 改进是什么?

r - 按因子级别对数据框进行子集化

function - Inno Setup Could not call proc 错误?

perl - 使用 SOAP 和 Perl 调用带参数的函数

c++ - 有没有一种方法可以使用默认模板参数而不必在 C++ 中使用 <>?

c++ - 字符可打印程序