Skip to content

Latest commit

 

History

History
106 lines (64 loc) · 1.75 KB

CppPublic.md

File metadata and controls

106 lines (64 loc) · 1.75 KB

 

 

 

 

 

 

public is a keyword for setting class access level to public (the other access levels are private and protected) or for public inheritance.

 

The public part of a class is called its interface.

 

A class created with the keyword class has a private access level by default, a class created by the keyword struct has public access level by default.

 

 

 

 

 

Examples

 

 

 

 

 

 

 

 

 

 

 

 

  1. Herb Sutter. Exceptional C++. ISBN: 0-201-61562-2. Item 23, page 84, guideline: 'Avoid public virtual functions; prefer using the Template Method pattern instead'
  2. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 20.7. Advice. page 611: '[11] Prefer public members for interfaces'