Why is my return type meaningless?

后端 未结 6 734
别跟我提以往
别跟我提以往 2021-01-11 16:05

I am trying to use a return type of const MyClass * const. However, I get a warning:

Warning: #815-D: type qualifier on return type is m

6条回答
  •  遥遥无期
    2021-01-11 16:40

    Why do you care if the pointer is changed? Doing this is like saying:

    const int f() {
       ...
    }
    

    The value returned by f() is a copy - changing it changes nothing, so there is nom point in making it const.

提交回复
热议问题