As shown below:
Final,override appears after the parameter list and the wake return type # include <iostream>using namespace std;struct b{ virtual void F1 (int) const; virtual void F2 (int); void F3 (int) final;//error, final cannot decorate non-virtual function};struct d:b{ void F1 (int) const override;//removing const will make an error and must be consistent with the function prototype in the base class. Otherwise, you cannot overwrite void F2 (int) with override to indicate that a derived class that inherits D cannot overwrite the function void F3 ();}; struct e:b{ void F2 (int),//ok, whose direct base class B does not have a final specifier};struct f:d{ void F2 (int);//error, cannot overwrite this function, The reason is that there is a final specifier in the direct base class D};
Final indicates that the virtual function cannot be overridden, and override indicates that the function overrides a virtual function
The above details C++11 final and the override specifier is a small part of the whole content to share to everyone, I hope to give you a reference, but also hope that we support topic.alibabacloud.com.