June 2025
Intermediate to advanced
1093 pages
33h 24m
English
A type that contains a constructor is no longer an aggregate; it is a structure. This term comes from the fact that you introduce the type declaration with struct.
You will sometimes hear the term class instead—and that is also correct, because instead of struct … you can just as well write class …. There is only a tiny difference in meaning between struct and class in C++:
structA struct initially has public access rights.
classA class starts with private access rights.
Having public access rights means that you can access the internals of the type from the outside. You saw this in the implementation of operator<<:
ostream& operator<<(ostream& os, Person p) { return p.print(os);}
The print method of the Person ...
Read now
Unlock full access