Covariant-Return-Types-and-Smart-Pointers:协变返回类型和智能指针

时间:2021-06-26 15:47:29
【文件属性】:
文件名称:Covariant-Return-Types-and-Smart-Pointers:协变返回类型和智能指针
文件大小:324KB
文件格式:ZIP
更新时间:2021-06-26 15:47:29
C++ 协变返回类型和智能指针 协变返回类型是一种语言功能,它允许您将虚函数的返回类型更改为协变类型,即。 指向派生类的指针而不是指向基类的指针 - 请参见下面的示例: struct Figure { virtual ~Figure () = default ; virtual Figure* clone () const = 0; // ... other methods }; struct Square : Figure { Square* clone () const override // return type is Square* instead of Figure* (Covariant Return Type) { return new Square (* this ); } // ... other methods }; 它编译并运行。 返回类
【文件预览】:
Covariant-Return-Types-and-Smart-Pointers-master
----CMakeLists.txt(461B)
----.gitignore(262B)
----README.md(9KB)
----FigureTests-v2.cpp(2KB)
----FigureTests-v1.cpp(2KB)
----3rd-party()
--------gmock-1.7.0()
----LICENSE(1KB)
----.gitattributes(483B)
----FigureTests-v5.cpp(2KB)
----FigureTests-v4.cpp(2KB)
----FigureTests-v3.cpp(2KB)

网友评论