• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. class oldCompany {
    5. public:
    6. virtual void marketing () {
    7. cout << "How old company does marketing." << endl;
    8. }
    9. };
    10.  
    11. class newCompany: public oldCompany {
    12. public:
    13. virtual void marketing () {
    14. cout << "Redefing marketing :D" << endl;
    15. }
    16. };
    17.  
    18.  
    19. int main() {
    20. newCompany newish;
    21. oldCompany oldish;
    22. oldish.marketing ();
    23. newish.marketing();
    24. return 0;
    25. }
    26.  
    27. /*
    28. Output:
    29.  
    30. How old company does marketing.
    31. Redefing marketing :D
    32. */