Meaning of 'const' last in a function declaration of a class?

后端 未结 10 2092
无人共我
无人共我 2020-11-21 06:37

What is the meaning of const in declarations like these? The const confuses me.

class foobar
{
  public:
     operator int () const         


        
10条回答
  •  被撕碎了的回忆
    2020-11-21 07:22

    when you use const in the method signature (like your said: const char* foo() const;) you are telling the compiler that memory pointed to by this can't be changed by this method (which is foo here).

提交回复
热议问题