struct Rect{
Rect(){
new(this) Rect(1, 2, 3, 4, 5, 6);
// left =1;
// top =2;
cout <<"left second:" << left <<endl;
}
Rect(int l, int t, int r, int b): Rect(l, t, r, b, 0, 0){
}
Rect(Point topleft, Point bottomright){
Rect(topleft.x, topleft.y,
bottomright.x, bottomright.y,
0, 0);
}
Rect(int l){
new(this) Rect();
cout <<"left third:" << left <<endl;
}
Rect(int l, int t, int r, int b, int lc, int fc){
left = l; top = t;
right = r; bottom = b;
line_color = lc;
fill_color = fc;
//do something else...
cout <<"left first:" << left <<endl;
}
int left;
int top;
int right;
int bottom;
int line_color;
int fill_color;
};
int main()
{
Rect(2);
}
Rect(2) 调用Rect(l),再调用r