C++ const keyword - use liberally?

前端 未结 12 2444
甜味超标
甜味超标 2020-12-04 18:12

In the following C++ functions:

void MyFunction(int age, House &purchased_house)
{
    ...
}


void MyFunction(const int age, House &purchased_house)         


        
12条回答
  •  广开言路
    2020-12-04 18:59

    You not only indicate that it will not change, it will prevent your code from thinking it can and it will be caught at compilation time.

提交回复
热议问题