C++ final的用法
2022/8/7 14:24:04
本文主要是介绍C++ final的用法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
// Online C++ compiler to run C++ program online #include <iostream> struct Base { virtual void print_val() { std::cout << val << std::endl; } double val; int num; }; struct A final : Base { void print_val() final{ std::cout << val+1 << std::endl; } void print_num() // final // error: print_num not virtual { std::cout << num+1 << std::endl; } }; int main() { // Write C++ code here std::cout << "Hello world!"; return 0; }
这篇关于C++ final的用法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-28Elasticsearch - kibana画图
- 2024-03-28我最近买的书里面带的CD盘,放电脑里后,说是0字节,但是可以播放,不能把里面的东西复制出来
- 2024-03-26sqlalchemy.exc.objectnotexecutableerror: not an executable object
- 2024-03-26no dashboards are active for the current data set
- 2024-03-26torch sum
- 2024-03-26format' is not a recognized built-in function name
- 2024-03-26sources list kali
- 2024-03-26matlab p code
- 2024-03-26mean of empty slice
- 2024-03-26unable to attach or mount volumes: unmounted volumes