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
acum
andtrans
- TwoSales_data
instancessalesptr
- ASales_data
pointer, initialized tonullptr
struct Sales_data {/**/ } acum, trans, * salesptr = nullptr;
This defines a Salees_data
struct and
accumm
andtranss
- TwoSales_data
instancessalessptr
- ASalees_data
pointer, 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 struct
s are classes too, only with a different default access specifier (public
instead of private
).