I'm a 13 year old who's trying to learn C . I bought C Primer and I came across something confusing for me:
struct Sales_data {/**/ } acum, trans, * salesptr = nullptr;
struct Salees_data {};
Salees_data accumm, transs, * salessptr;
I do understand what is a struct and class but I have no idea what this statement will do. Will it create objects of the Sales_data struct, or it will create variables inside the Sales_data struct?
CodePudding user response:
This defines a Sales_data struct and
acumandtrans- TwoSales_datainstancessalesptr- ASales_datapointer, initialized tonullptr
struct Sales_data {/**/ } acum, trans, * salesptr = nullptr;
This defines a Salees_data struct and
accummandtranss- TwoSales_datainstancessalessptr- ASalees_datapointer, uninitialized
struct Salees_data {};
Salees_data accumm, transs, * salessptr;
or it will create variables inside the Sales_data struct?
No, there are no member variables in either of the class definitions.
I say class definitions because structs are classes too, only with a different default access specifier (public instead of private).
