Skip to content

Instantly share code, notes, and snippets.

@doches
Created August 2, 2010 17:03
Show Gist options
  • Save doches/504953 to your computer and use it in GitHub Desktop.
Save doches/504953 to your computer and use it in GitHub Desktop.
Example C++ Header/Code files
// object.h (the header file)
#include <iostream>
class H
{
public:
H(int v);
void print();
protected:
int value;
};
// object.cpp (the code file)
#include "object.h"
// Note: this could be more compactly (and more C++-idiomatically!) written as:
// H::H(int v) : value(v) { }
H::H(int v)
{
this->value = v;
}
void H::print()
{
std::cout << this->value << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment