Last active
March 3, 2019 08:02
-
-
Save frankie-yanfeng/6868efded7b129b604b21ab0fd1749d5 to your computer and use it in GitHub Desktop.
C++ enclosing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CTyre { //轮胎类 | |
private: | |
int radius; //半径 | |
int width; //宽度 | |
public: | |
CTyre(int r, int w):radius(r), width(w) { } | |
}; | |
class CEngine { //引擎类 | |
}; | |
class CCar { //汽车类 | |
private: | |
int price; //价格 | |
CTyre tyre; | |
CEngine engine; | |
public: | |
CCar(int p, int tr, int tw); | |
}; | |
CCar::CCar(int p, int tr, int w):price(p), tyre(tr, w) | |
{ | |
}; | |
int main(){ | |
CCar car(20000,17,225); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment