New OOP
This commit is contained in:
38
Object-Oriented-Programming/嵌套类.cpp
Normal file
38
Object-Oriented-Programming/嵌套类.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
class Engine{
|
||||||
|
public:
|
||||||
|
int layer1;
|
||||||
|
class WaterTank{
|
||||||
|
public:
|
||||||
|
int layer3;
|
||||||
|
class Water{
|
||||||
|
public:
|
||||||
|
int layer5;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
int layer8;
|
||||||
|
class Tank{
|
||||||
|
public:
|
||||||
|
int layer9;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
int layer2;
|
||||||
|
class EngineRope{
|
||||||
|
public:
|
||||||
|
int layer6;
|
||||||
|
class Rope{
|
||||||
|
public:
|
||||||
|
int layer7;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
Engine A;
|
||||||
|
cout << A.layer1 << A.WaterTank.layer3 << A.WaterTank.Water.layer5
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user