C structs don't define types?

前端 未结 10 2301
离开以前
离开以前 2021-01-21 06:54

I\'ve just started learning C with a professional Java background and some (if no too much) C++ knowledge, and I was astonished that this doesn\'t work in C:

str         


        
10条回答
  •  死守一世寂寞
    2021-01-21 07:02

    That's the way C works. In C you have to say:

    typedef struct Point {
        int x;
        int y;
    } Point;
    

    And then you'll have a type called Point that does what you want.

    In C++ it's enough to define it the way you did.

提交回复
热议问题