导航

2014年4月2日

摘要: 1,C++在定义函数重载的时候形参不管是不是const的他们都是等价的,除非形参是const引用。举个例子:void fun(int a){...}与void fun(const int a){...}是等价的,这样重载会报错说redefinition。void fun(int &a){...}与void fun(const int &a){...}这样就是正确的。2,不能从const成员函数返回指向类对象的普通引用,const成员函数只能返回*this作为一个const引用。const test_const &fun()const{...;return *this} 阅读全文

posted @ 2014-04-02 14:51 网名还没想好 阅读(452) 评论(0) 推荐(0) 编辑