×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / C++ language question
    virtual bool Find(const tt_achar *name, const tt_achar *password) const ;

    What does the 'const' at the end of function mean?
    • that const means this member function does not change any member variable.
      • Thanks. you buddy.
    • run this code to see what the second const mean:
      #include "stdio.h"
      class a
      {
      public:
      void f(){printf("non const version\n");};
      void f()const{printf("const version\n");};
      };

      void main()
      {
      a instanceofa;
      const a constantinstanceofa;
      instanceofa.f();
      constantinstanceofa.f();
      }

      in fact, besides meaning it should change nothing of the instance, it also stands for a selector.
      • Exellent, really exellet!