Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) public

 

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.

 

class Test
{
  public:
  void YouCanCallMe();
  private:
  void YouCannotCallMe();
};

int main()
{
  Test t;
  t.YouCanCallMe();
  t.YouCannotCallMe(); //Illegal
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict