关于重载

重载显然是指的函数形参列表,与返回值没有什么关系,与形参名更没有什么关系!

// 返回值不同,形参列表相同,重复声明
Record lookup(const Account&);
bool lookup(const Account&);

// 非引用const和非引用,重复声明
bool lookup(Account);
boot lookup(const Account);

// 引用const与引用,重载
bool lookup(Account&);
bool lookup(const Account&);

// const指针与指针,重载,除非使用const_cast<type>()
bool lookup(Account *);
bool lookup(const Account *);

// 下面的重载是合法的
class Foo
{
void foo(void) const;
void foo(void);
};

// 下面的重载是不合法的
class Foo
{
const Foo foo(void);
Foo foo(void);
};

 

posted @ 2014-10-09 18:54  WendellYih  阅读(183)  评论(0编辑  收藏  举报