当前位置:网站首页>(P14) use of the override keyword
(P14) use of the override keyword
2022-06-12 08:26:00 【Ordinary people who like playing basketball】
List of articles
1.override
override Keyword ensures that the overriding function declared in the derived class has the same signature as the virtual function of the base class , It also makes it clear that the virtual function of the base class will be overridden , In this way, the correctness of the rewritten virtual function can be guaranteed , It also improves the readability of the code , and final The same keyword should be written after the method .
How to use it is as follows :
Of the following codes 13 Xing He 22 The row shows the specified parent class to override test() Method , Used override After keyword , Suppose that in the rewriting process, due to misoperation , If you write the wrong function name or function parameter or return value, the compiler will prompt syntax error , Improve the correctness of the program , It reduces the probability of error .The purpose is : Improve program readability
class Base
{
public:
virtual void test()
{
cout << "Base class...";
}
};
class Child : public Base
{
public:
void test() override
{
cout << "Child class...";
}
};
class GrandChild : public Child
{
public:
void test() override
{
cout << "Child class...";
}
};
- Reference resources :final and override
边栏推荐
- In the era of intelligent manufacturing, how do enterprises carry out digital transformation
- At present, MES is widely used. Why are there few APS scheduling systems? Why?
- Ceres optimizer usage (self use)
- Hands on deep learning -- weight decay and code implementation
- Group planning chapter I
- Hands on learning and deep learning -- a brief introduction to softmax regression
- Hands on deep learning -- activation function and code implementation of multi-layer perceptron
- (P19-P20)委托构造函数(代理构造函数)和继承构造函数(使用using)
- ctfshow web4
- MES帮助企业智能化改造,提高企业生产透明度
猜你喜欢

ctfshow web3

智能制造的时代,企业如何进行数字化转型

Introduction to SDI video data stream format (frequency, rate, YUV, EAV, SAV)

Detailed explanation of Google open source sfmlearner paper combining in-depth learning slam -unsupervised learning of depth and ego motion from video

Model Trick | CVPR 2022 Oral - Stochastic Backpropagation A Memory Efficient Strategy

X64dbg debugging exception_ ACCESS_ VIOLATION C0000005

The electrical fire detector monitors each power circuit in real time

ctfshow web 1-2

Figure neural network makes Google maps more intelligent

Ankerui fire emergency lighting and evacuation indication system
随机推荐
Figure neural network makes Google maps more intelligent
Discrete chapter I
MYSQL中的调用存储过程,变量的定义,
Detailed explanation of Google open source sfmlearner paper combining in-depth learning slam -unsupervised learning of depth and ego motion from video
Record the treading pit of grain Mall (I)
Lock mechanism in MySQL
What kind of sparks will be generated when the remote sensing satellite meets the Beidou navigation satellite?
Strvec class mobile copy
Summary of 3D point cloud construction plane method
Production scheduling status of manufacturing enterprises and solutions of APS system
What exactly is APS? You will know after reading the article
(p36-p39) right value and right value reference, role and use of right value reference, derivation of undetermined reference type, and transfer of right value reference
报错:清除网站内搜索框中的历史记录?
后MES系统的时代,已逐渐到来
Xiaomi mobile phone recording data set software operation
MATLAB image processing -- image transformation correction second-order fitting
建立MES系统,需要注意什么?能给企业带来什么好处?
ctfshow web3
(P13)final关键字的使用
What is an extension method- What are Extension Methods?