mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-03 10:33:25 +08:00
update
This commit is contained in:
36
basic_content/using/using_derived.cpp
Normal file
36
basic_content/using/using_derived.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @file using_derived.cpp
|
||||
* @brief 函数重装
|
||||
* @author 光城
|
||||
* @version v1
|
||||
* @date 2019-08-07
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class Base{
|
||||
public:
|
||||
void f(){ cout<<"f()"<<endl;
|
||||
}
|
||||
void f(int n){
|
||||
cout<<"Base::f(int)"<<endl;
|
||||
}
|
||||
};
|
||||
|
||||
class Derived : private Base {
|
||||
public:
|
||||
using Base::f;
|
||||
void f(int n){
|
||||
cout<<"Derived::f(int)"<<endl;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Base b;
|
||||
Derived d;
|
||||
d.f();
|
||||
d.f(1);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user