mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-18 18:44:35 +03:00
28
README.md
28
README.md
@@ -53,6 +53,7 @@ C++11 includes the following new language features:
|
|||||||
- [delegating constructors](#delegating-constructors)
|
- [delegating constructors](#delegating-constructors)
|
||||||
- [user-defined literals](#user-defined-literals)
|
- [user-defined literals](#user-defined-literals)
|
||||||
- [explicit virtual overrides](#explicit-virtual-overrides)
|
- [explicit virtual overrides](#explicit-virtual-overrides)
|
||||||
|
- [final specifier](#final-specifier)
|
||||||
- [default functions](#default-functions)
|
- [default functions](#default-functions)
|
||||||
- [deleted functions](#deleted-functions)
|
- [deleted functions](#deleted-functions)
|
||||||
- [range-based for loops](#range-based-for-loops)
|
- [range-based for loops](#range-based-for-loops)
|
||||||
@@ -793,6 +794,33 @@ struct B : A {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Final specifier
|
||||||
|
Specifies that a virtual function cannot be overridden in a derived class or that a class cannot be inherited from.
|
||||||
|
```c++
|
||||||
|
struct A {
|
||||||
|
virtual void foo();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct B : A {
|
||||||
|
virtual void foo() final;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct C : B {
|
||||||
|
virtual void foo(); // error -- declaration of 'foo' overrides a 'final' function
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Class cannot be inherited from.
|
||||||
|
```c++
|
||||||
|
struct A final {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct B : A { // error -- base 'A' is marked 'final'
|
||||||
|
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
### Default functions
|
### Default functions
|
||||||
A more elegant, efficient way to provide a default implementation of a function, such as a constructor.
|
A more elegant, efficient way to provide a default implementation of a function, such as a constructor.
|
||||||
```c++
|
```c++
|
||||||
|
|||||||
Reference in New Issue
Block a user