CPlusPlusThings/struct_class/ext_struct_func.cpp
2019-07-26 20:02:15 +08:00

29 lines
451 B
C++

#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;
}