c++ - "invalid use of member"尝试使用我的功能时

标签 c++ compiler-errors

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

2年前关闭。




Improve this question




我正在尝试解决平衡括号问题,在我的代码中,如果我的堆栈顶部为空,我试图从函数 is_empty() 中获取 1,但是我在这里遇到了这个丑陋的错误。

int is_Empty()
{
    int x=0;
    if (top==NULL)
    {
    x=1;
    }
    return x;
}

这是我如何接受它
if (s1.is_Empty==1)
    {
        cout<<"matched"<<endl;
    }

我的错误日志
bal.cpp:112:20: error: invalid use of member 'int stack::is_Empty()' (did you forget the '&' ?)        
             if (s1.is_Empty==1)
                 ~~~^~~~~~~~

最佳答案

if (s1.is_Empty==1)

这不是调用函数的方式。

这里:
if (s1.is_Empty()==1)

您可能希望查看您的 C++ 书籍。

关于c++ - "invalid use of member"尝试使用我的功能时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57697609/

相关文章:

c++ - 在 C 中有效地解析 char 数组

c++ - 以随机可再现顺序生成非重复字节的快速方法

java - 无法编译包含非 ASCII 字符的 Java 文件

python - OWASP ZAP python API错误运行脚本

c++ - static_assert(std::is_abstract) 在 Visual Studio 2013 中导致编译器错误

c++ - 尝试将存储在 char 中的时间转换为正常形式。打印一个随机值。怎么了?

c++ - exe在同一目录下找不到文本文件

ios - Xcode降级错误

c - 出现错误 "assignment makes pointer from integer without a cast"

c++ - C++ 中的 "Undefined symbols"错误