# Rectangle2.cpp ```cpp= #include<stdio.h> class Rectangle { // 定義一個 Rectangle 類型 public: int width; int height; int area() { return width * height; } }; int main() { Rectangle r1; // 宣告一個 Rectangle 「物件」,名字叫做 r1 Rectangle r2; // 宣告一個 Rectangle 「物件」,名字叫做 r2 r1.width = 3; r1.height = 4; r2.width = 5; r2.height = 6; printf("%d\n", r1.area()); printf("%d\n", r2.area()); return 0; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up