What does “const class” mean?

前端 未结 5 1885
不思量自难忘°
不思量自难忘° 2020-12-14 14:34

After some find and replace refactoring I ended up with this gem:

const class A
{
};

What does \"const class\" mean? It seems to compile ok

5条回答
  •  渐次进展
    2020-12-14 15:33

    Try compiling it with GCC, it will give you below error:
    error: qualifiers can only be specified for objects and functions.

    As you can see from the error that only objects(variables, pointers, class objects etc.) and functions can be constant. So try making the object as constant, then it should compile fine.
    const class A {};
    const A a ;

提交回复
热议问题