Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

function overriding in c++

// C++ program to demonstrate function overriding

#include <iostream>
using namespace std;

class Base {
   public:
    void print() {
        cout << "Base Function" << endl;
    }
};

class Derived : public Base {
   public:
    void print() {
        cout << "Derived Function" << endl;
    }
};

int main() {
    Derived derived1;
    derived1.print();
    return 0;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #function #overriding
ADD COMMENT
Topic
Name
7+9 =