Skip to content

Instantly share code, notes, and snippets.

@dideler
Last active March 20, 2017 21:13
Show Gist options
  • Save dideler/5537024 to your computer and use it in GitHub Desktop.
Save dideler/5537024 to your computer and use it in GitHub Desktop.
C++ notes
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
};

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment