// 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;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/279298.html