I have two structures declared this way:
struct dot {
int x, y;
};
struct pig : dot {
int z;
};
I can declare dot variable like this:
dot a = {1, 100};
But how can I declare pig variable? The only way I found is this:
pig b;
b.x = 1;
b.y = 100;
b.z = 2134;
Is there any way to do it easier, like with dot variables?
I tried this:
pig b = {1, 100, 2133}
but it doesn't work.
Please, help!
Here's what I was looking for:
struct dot {
int x, y;
};
struct pig : dot {
int z;
pig(int x_, int y_, int z_) : dot{x_, y_}, z{z_} {}
};
pig b{1, 2, 3};