mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-04 02:54:42 +08:00
update dir
This commit is contained in:
28
struct/ext_struct_func.cpp
Normal file
28
struct/ext_struct_func.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include<iostream>
|
||||
#include<stdio.h>
|
||||
|
||||
struct Base {
|
||||
int v1;
|
||||
// private: //error!
|
||||
int v3;
|
||||
public: //显示声明public
|
||||
int v2;
|
||||
virtual void print(){
|
||||
printf("%s\n","Base");
|
||||
};
|
||||
};
|
||||
|
||||
struct Derived:Base {
|
||||
|
||||
public:
|
||||
int v2;
|
||||
void print(){
|
||||
printf("%s\n","Derived");
|
||||
};
|
||||
};
|
||||
|
||||
int main() {
|
||||
Base *b=new Derived();
|
||||
b->print();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user