相关疑难解决方法(0)

为什么IBM XL C/C++编译器出现此警告?

这是一个说明问题的最小代码示例:

#include <iostream>

class Thing
{
   // Non-copyable
   Thing(const Thing&);
   Thing& operator=(const Thing&);

   int n_;

public:
   Thing(int n) : n_(n) {}

   int getValue() const { return n_;}
};

void show(const Thing& t)
{
   std::cout << t.getValue() << std::endl;
}

int main()
{
   show(3);
}
Run Code Online (Sandbox Code Playgroud)

这会产生相同的错误:

int main()
{
    show( Thing(3) );
}
Run Code Online (Sandbox Code Playgroud)

AIX下的IBM XL C/C++ 8.0编译器会发出以下警告:

"testWarning.cpp", line 24.9: 1540-0306 (W) The "private" copy constructor "Thing(const Thing &)" cannot be accessed.
"testWarning.cpp", line 24.9: 1540-0308 (I) The semantics specify that …
Run Code Online (Sandbox Code Playgroud)

c++ aix compiler-warnings

8
推荐指数
1
解决办法
675
查看次数

标签 统计

aix ×1

c++ ×1

compiler-warnings ×1