我见过代码,人们将使用const作为函数的参数.使用const*vs const*const有什么好处?这可能是一个非常基本的问题,但如果有人能够解释,我将不胜感激.
Bool IsThisNumberEqualToFive(int const * num)
{
return(Bool)(5 != num );
}
Bool IsThisNumberEqualToFive(int const * const num)
{
return(Bool)(5 != num );
}
Run Code Online (Sandbox Code Playgroud)
num指向num指向别的东西.也就是说,在第二个版本中,指针本身也是const指针对象.