1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
class Base {
public:
virtual void show() final {
std::cout << "Base class show function" << std::endl;
}
};
class Derived : public Base {
public:
// This will cause a compile-time error
// void show() override {
// std::cout << "Derived class show function" << std::endl;
// }
};
int main() {
Derived d;
d.show(); // Calls Base::show()
return 0;
}
Back to final