dideler
5/7/2013 - 11:28 PM

C++ notes

C++ notes

A header file (e.g. .h) describes the classes that are declared in the file with an overview of what they are for and how they are used. In other words, it's documentation for the user of the library.

A body file (e.g. .cpp) should contain more information about implementation details or discussions of tricky algorithms. In other words, it's documentation for the maintainer.

class A 
{
 public:
  int x;
 protected:
  int y;
 private:
  int z;
};

class B : public A
{
  // x is public
  // y is protected
  // z is not accessible from B
};

class C : protected A
{
  // x is protected
  // y is protected
  // z is not accessible from C
};

class D : private A
{
  // x is private
  // y is private
  // z is not accessible from D
};