A quick question about C ++ structures, to which I could not find the answer:
I read that the only difference between structures and classes is the visibility of members. So, does the compiler provide the structure with a default constructor? (and by default copyconstructor, destructor and assignment operator?) And can you define all of the above yourself?
Thanks, Istvan
Yes it is, and yes you can.
Yes to all your questions. The same is true for classes.
, - .
. , :
struct S1 { int m1; }; struct S2: S1 { int m2; };
S2, m2 m1 . S2* , S1*.
S2*
S1*
++ class a struct , , struct - . , , , . .
class
struct
.
struct TestStruct { int id; TestStruct() : id(42) { } };
question.