Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
33 lines (25 loc) · 787 Bytes

File metadata and controls

33 lines (25 loc) · 787 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// Created by light on 19-11-3.
//
#include <iostream>
using namespace std;
// final关键字用于两个地方
// 第一个用在类,用于说明该类是继承体系下最后的一个类,不要其他类继承我,当继承时就会报错。
class Base final {
public:
Base() {}
virtual void func() {}
};
class Derivered : public Base { // error: cannot derive from ‘final’ base ‘Base’ in derived type ‘Derivered’
};
// 第二个用在虚函数,表示这个虚函数不能再被override了,再override就会报错。
class Base1 {
public:
Base1() {}
virtual void func() final {}
};
class Derivered1 : public Base1 {
virtual void func() {} // error: overriding final function ‘virtual void Base1::func()’
};
int main() {
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.