mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-03 18:43:52 +08:00
support bazel complie this project and format code.
This commit is contained in:
@@ -1,33 +1,31 @@
|
||||
#include<iostream>
|
||||
#include<stdio.h>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
using namespace std;
|
||||
struct Base {
|
||||
int v1;
|
||||
// private: //error!
|
||||
int v3;
|
||||
public: //显示声明public
|
||||
int v2;
|
||||
virtual void print(){
|
||||
printf("%s\n","Base");
|
||||
};
|
||||
Base(){cout<<"Base construct"<<endl;};
|
||||
virtual ~Base(){cout<<"Base deconstruct"<<endl;};
|
||||
struct Base {
|
||||
int v1;
|
||||
// private: //error!
|
||||
int v3;
|
||||
|
||||
public: // 显示声明public
|
||||
int v2;
|
||||
virtual void print() { printf("%s\n", "Base"); };
|
||||
Base() { cout << "Base construct" << endl; };
|
||||
virtual ~Base() { cout << "Base deconstruct" << endl; };
|
||||
};
|
||||
|
||||
struct Derived:Base {
|
||||
struct Derived : Base {
|
||||
|
||||
Derived(){cout<<"Derived construct"<<endl;};
|
||||
virtual ~Derived(){cout<<"Derived deconstruct"<<endl;};
|
||||
public:
|
||||
int v2;
|
||||
void print(){
|
||||
printf("%s\n","Derived");
|
||||
};
|
||||
Derived() { cout << "Derived construct" << endl; };
|
||||
virtual ~Derived() { cout << "Derived deconstruct" << endl; };
|
||||
|
||||
public:
|
||||
int v2;
|
||||
void print() { printf("%s\n", "Derived"); };
|
||||
};
|
||||
|
||||
int main() {
|
||||
Base *b=new Derived();
|
||||
b->print();
|
||||
delete b;
|
||||
return 0;
|
||||
Base *b = new Derived();
|
||||
b->print();
|
||||
delete b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user