Skip to content

Instantly share code, notes, and snippets.

@frankie-yanfeng
Last active March 3, 2019 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankie-yanfeng/6868efded7b129b604b21ab0fd1749d5 to your computer and use it in GitHub Desktop.
Save frankie-yanfeng/6868efded7b129b604b21ab0fd1749d5 to your computer and use it in GitHub Desktop.
C++ enclosing
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