mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-10 14:05:28 +08:00
update dir
This commit is contained in:
32
abstract/derived_full.cpp
Normal file
32
abstract/derived_full.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @file derived_full.cpp
|
||||
* @brief 完整示例!抽象类由派生类继承实现!
|
||||
* @author 光城
|
||||
* @version v1
|
||||
* @date 2019-07-20
|
||||
*/
|
||||
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
class Base
|
||||
{
|
||||
int x;
|
||||
public:
|
||||
virtual void fun() = 0;
|
||||
int getX() { return x; }
|
||||
};
|
||||
|
||||
class Derived: public Base
|
||||
{
|
||||
int y;
|
||||
public:
|
||||
void fun() { cout << "fun() called"; } ///< 实现了fun()函数
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Derived d;
|
||||
d.fun();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user