This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / C++ language questionvirtual bool Find(const tt_achar *name, const tt_achar *password) const ;
What does the 'const' at the end of function mean?
-jami(jami);
2001-7-12
{129}
(#129270@0)
-
that const means this member function does not change any member variable.
-mrviceroy(杀人者Daniel是也);
2001-7-12
(#129280@0)
-
Thanks. you buddy.
-jami(jami);
2001-7-12
(#129282@0)
-
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.
-blaise(blaise);
2001-7-12
{362}
(#129525@0)
-
Exellent, really exellet!
-jami(jami);
2001-7-12
(#129580@0)