c++ - ‘.’ token 之前应有非限定 ID

标签 c++ linux

我收到此错误;

expected unqualified-id before ‘.’ token

对于以下代码;

void CLog::featureAvailable(const LogString_t* const featureName, const LogString_t* const additionalInfo) const
{
    if(NULL!=additionalInfo)
    {
        CLog.info(AV_LTPROF, additionalInfo); // error here
    }
    else
    {
        CLog.info(AV_LTPROF); // error here
    }
}

我不明白为什么?

最佳答案

显示的类方法

CLog::featureAvailable(/*...*/)

表示CLog是一个类,不带实例变量访问成员的语法不是.运算符,而是作用域解析运算符::

因此;

Clog::info(AV_LTPROF, additionalInfo);

或者使用明确的this;

this->info(AV_LTPROF, additionalInfo);

或者使用隐式this;

info(AV_LTPROF, additionalInfo);

没有显示 info() 方法,因此不清楚它是否是static

关于c++ - ‘.’ token 之前应有非限定 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37613030/

相关文章:

c++ - 验证给定 C++ 编译器是否将源代码读取为 C++11 的快速简单代码是什么?

c++ - 如何保存 vector 中的位置以供以后插入?

c++ - EXC_BAD_ACCESS 抛出异常

c++ - 重载运算符 +

c++ - 我可以在C/C++中(在Linux上)将`a.out`文件转换为“可执行文件”吗?

linux - Hadoop - 列出 HDFS 目录中的所有子目录并将每个目录路径保存到 bash 变量中

php - 如何使 Linux 服务器 URL 不区分大小写?

c++ - 哪些设置方法性能更好 : with or without `const&` ?

linux - 如何执行特定于文件的命令?

c - Boomerang:无法加载 libQtGUI