Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement homonym override, function rewriting and Polymorphism in C++

Shulou Source: shulou.com Published: 2022-06-03 09:06:07 11月15日 Update

This article is about how C++ implements homonym overrides, function rewriting and polymorphism. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Override # includeusing namespace std;class Base {public: int masked data; Base (): m_data (1) / / parent class initialized to 1 {}}; class Derived: public Base {public: int masked data; Derived (): m_data (2) / / subclass initialized to 2 {}}; int main () {Derived d / / the m_data of the parent class is hidden, but it still exists. You can access cout through the:: character

Tags: Functions objects polymorphisms subclasses results members pointers pointing running clocking keywords keywords meaning properties two content address actual time tone more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information macOS Shulou Tech Info OPPO Reno