Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8341f6e

Browse files
overring functions
1 parent 07e4991 commit 8341f6e

File tree

1 file changed

+42
-0
lines changed
  • Learn_CPP_Programming_Deep_Dive/Section 15 Polymorphism/Function_overloading

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
class Parent
6+
{
7+
public:
8+
void display()
9+
{
10+
cout<<"Display from base"<<endl;
11+
}
12+
13+
void preview()
14+
{
15+
cout<<"Preview from Parent"<<endl;
16+
}
17+
};
18+
19+
class Child: public Parent
20+
{
21+
public:
22+
void display() // overriding
23+
{
24+
cout<<"Display from Child"<<endl;
25+
}
26+
27+
void preview(int x) // function overloading
28+
{
29+
cout<<"Preview from Child overloaded"<<endl;
30+
}
31+
};
32+
33+
34+
int main(void)
35+
{
36+
Child c;
37+
c.display();
38+
c.preview(10);
39+
c.Parent::preview();
40+
41+
return 0;
42+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /