覆盖虚函数时的返回值(Return type of an overriding virtual member function)
来源:互联网 发布:第三方数据服务商 编辑:程序博客网 时间:2024/06/05 14:12
http://www.devx.com/tips/Tip/12476
Once declared virtual, a member function can be overridden in any level of derivation, as long as the overriding version has the identical signature of the original declaration. This is quite straightforward, but sometimes a virtual has to return an object of type that differs from the return type declared in its base class. The C++ Standard allows that only when the return type is replaced with a class publicly derived from the original return type. For example:
class B {
virtual B* clone () const { return new B; }
}
class D {
void* clone () const { return new B; } //error; return type
//differs
D* clone () const { return new D; } //OK, D is publicly
//derived from B
}
- 覆盖虚函数时的返回值(Return type of an overriding virtual member function)
- 043.Return Type 函数的返回值
- 043.Return Type 函数的返回值
- const member function can return non-const type member vars
- C语言主函数返回值问题:return type of 'main' is not 'int' [-Wmain]
- C++ virtual member function
- 虚函数(virtual function)
- 081.Return Pointer Function 返回指针的函数
- 081.Return Pointer Function 返回指针的函数
- Function Pointer of class member function (类的成员函数指针)
- Function Pointer of class member function C++的类成员函数指针简要
- Function Pointer of class member function (类的成员函数指针)
- function 函数传参,不定参,return返回值
- 虚函数(virtual function)
- C++ virtual member function FAQ
- C++ virtual member function FAQ
- 牛客 题库 virtual虚函数的覆盖
- 函数重载(OverLoading)和函数的覆盖(重写)Overriding
- 图解kset,kobject,subsys
- SQL 问题与解答 - 数据库移动、性能优化、备份和镜像
- 连接池的基本工作原理
- As3.0 删除容器所有子对象
- 大型数据库设计原则
- 覆盖虚函数时的返回值(Return type of an overriding virtual member function)
- SQL操作全集
- 再次遇到 undefined reference to `vtable for XXXX'
- 乔布斯——一个不朽的传说
- SQL 备份语句
- VB连接SQL数据库实例
- 使用rvm安装ruby on rails
- 【KM算法求最大权匹配】hdu 3722
- Eclipse引用外部project