const before parameter vs const after function name c++

后端 未结 7 2131
梦如初夏
梦如初夏 2020-12-07 06:41

What is the difference betweeen something like this

friend Circle copy(const Circle &);

and something like this

friend          


        
7条回答
  •  忘掉有多难
    2020-12-07 07:44

    friend Circle copy(const Circle &);
    

    The value of parameter will not be changed during the function calls.

    friend Circle copy(const Circle &)const ; 
    

    The function is an accessor that does not change any value of class members. Generally, there are to types of functions: accessors and mutators. Accessor: examines but does not change the state of its object.

提交回复
热议问题