What will happen if a virtual function is declared to be virtual again in a derived class?

X

Xiangliang Meng

Hi, all.

What will happen if a virtual function is declared to be virtual again in a
derived class? Any harm?

Best Regards,

Xiangliang Meng
 
E

E. Robert Tisdale

Xiangliang said:
What will happen if a virtual function
is declared to be virtual again in a derived class? Any harm?

No harm.
In fact, I recommend it.
 
J

Jack Klein

Hi, all.

What will happen if a virtual function is declared to be virtual again in a
derived class? Any harm?

Best Regards,

Xiangliang Meng

No harm at all. Any function defined as virtual in a base class is
always virtual in derived classes, whether you use the virtual keyword
in the derived class or not. Most experienced C++ programmers seem to
prefer using the virtual keyword in the derived class for
documentation purposes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top