const before parameter vs const after function name c++

后端 未结 7 2123
梦如初夏
梦如初夏 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:40

    friend Circle copy(const Circle &);//refers to constant parameter of the function. cant' change the value stored by parameter.

    Need to remove friend in your example Circle copy(Circle&) const; //can't change this poniter value named as Constant member function

提交回复
热议问题