When I define some random structure like for example in a cpp file in Visual studio
1) struct CAddition {
int x, y;
CAddition(int a, int b) { x = a; y = b; }
int result() { return x + y; }
};
and now if I define some structure object
CAddition foo;
it works without any error but if I use any alias in the end
2) struct CAddition {
int x, y;
CAddition(int a, int b) { x = a; y = b; }
int result() { return x + y; }
}CAddition;
I cannot simply define any object without using struct before the definition
struct CAddition foo;
or an alternative method would be to add
typedef struct CAddition {
In the method 2 to avoid rewriting struct every time , My question is whats the difference between these 2 definitions , doesn't method 1 use less keywords and much easier to use in what conditions should we use the second definition of a structure.