-
Notifications
You must be signed in to change notification settings - Fork 5
google cppguide
Shuai YUAN edited this page Oct 18, 2022
·
3 revisions
https://google.github.io/styleguide/cppguide.html
Avoid virtual method calls in constructors, and avoid initialization that can fail if you can't signal an error.
Composition is often more appropriate than inheritance. When using inheritance, make it public
.
Multiple inheritance is allowed only when all superclasses, with the possible exception of the first one, are pure interfaces. In order to ensure that they remain pure interfaces, they must end with the Interface suffix.
A class is a pure interface if it meets the following requirements:
- It has only public pure virtual ("= 0") methods and static methods (but see below for destructor).
- It may not have non-static data members.
- It need not have any constructors defined. If a constructor is provided, it must take no arguments and it must be protected.
- If it is a subclass, it may only be derived from classes that satisfy these conditions and are tagged with the Interface suffix.