Cpp主要方法const声明

时间:2017-12-13 06:01:48

标签: c++ const main

为什么我们不能在CPP中将main方法声明为const?

int main() const 
{
   //Some code
}

有人可以告诉我为什么?

1 个答案:

答案 0 :(得分:1)

  

为什么我们不能在CPP中将main方法声明为const?

shard server限定符只能用于声明类的成员函数。它不是非成员函数的选项,const是一个。

相关问题