How to declare structure?

Revision en5, by ivanz, 2021-05-20 19:39:06

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!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English ivanz 2021-05-20 19:45:07 219
en5 English ivanz 2021-05-20 19:39:06 3 Tiny change: ' \n} \n~~~~~\n' -> ' \n}; \n~~~~~\n'
en4 English ivanz 2021-05-20 14:57:17 2 Tiny change: '\n int a; ' -> '\n int z; '
en3 English ivanz 2021-05-20 14:47:36 66
en2 English ivanz 2021-05-20 14:46:34 390
en1 English ivanz 2021-05-20 14:45:13 1643 Initial revision (published)