Details c++11 final and override specifiers

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.