本文介绍了如何覆盖好的风格的虚拟函数? [C ++]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题是非常基本的,但我已经在少数出版物(网站,书籍)遇到不同风格的覆盖虚拟功能。我的意思是:如果我有基类:

  class Base 
{
public:
virtual void f()= 0;
};

在某些出版物中,我看到要覆盖这些一些作者只会说:

  void f(); 

,有些人仍然会在void之前重复virtual关键字。哪种形式的覆盖是好的风格?
谢谢您的答案。

解决方案

这只是一个问题。关于一些风格的自我记录价值与其他风格的非冗余性,可以对一些弱论据进行反复。


guys I know this question is very basic but I've met in few publications (websites, books) different style of override virtual function. What I mean is: if I have base class:

class Base
{
public:
virtual void f() = 0;
};

in some publications I saw that to override this some authors would just say:

void f();

and some would still repeat the virtual keyword before void. Which form of overwriting is in good style?Thank you for your answers.

解决方案

This is purely a matter of taste. Some weak arguments can be made back and forth as to the self-documentation value of some styles versus the non-redundancy of others.

这篇关于如何覆盖好的风格的虚拟函数? [C ++]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 12:52