Let's say I have two classes: Box, Circle.
class Box{
int x, y;
...Box(int xcoord, int ycoord){printf("I'm a box."); x = xcoord; y = ycoord;}
};
class Circle{
...Circle(){printf("I'm a circle.");}
};
But let's say in the Circle class, I want to make an instance of the Box class. Well I tried this:
class Circle{
Box b(0,0);
...Circle(){printf("I'm a circle.");}
};
I get an error:
error C2059: syntax error : 'constant'
class Circle {
Box b;
public:
Circle() : b(0, 0)
{
printf("I'm a circle.");
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With