function overriding in c++ code example
Example 1: c++ function overload
#include <iostream>
using namespace std;
int function1(int var1){
}
int function1(int var1,int var2){
}
int function1(int var1,string var3){
}
int main(){
cout << "Hello World" << endl;
function1(4);
function1(3,-90);
function1(34,"it works");
return 0;
}
Example 2: function overriding in oop c++
#include<iostream>
using namespace std;
class Base
{
public:
virtual void show()
{
cout << "Base class";
}
};
class Derived:public Base
{
public:
void show()
{
cout << "Derived Class";
}
};
int main()
{
Base* b;
Derived d;
b = &d;
b->show();
}