std;
Rectangle {
width, height;
:
Rectangle ();
Rectangle ();
area () { (width*height);}
};
Rectangle::Rectangle () {
width = 5;
height = 5;
}
Rectangle::Rectangle (int a, b) {
width = a;
height = b;
}
main () {
Rectangle rect (3,4);
Rectangle rectb;
cout << "rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
0;
}
(default constructor)。默認構造函數是的,它之所以特殊,是因為
,如果寫上,則不能調用 默認構造函數: