#ifndef _THING_H_ // Use to avoid including
the same file more than once.
#define _THING_H_ // Note: #ifndef
matches with #endif at the end of file.
// The first time this file name appears in a #include
// statement _THING_H_ is
undefined, so #ifndef is
true,
// and the C++ preprocessor includes all statements
// between the #ifndef and #endif.
#define causes
// _THING_H_ to
become defined. Thus, any subsequent
// executions of
#include Thing.h will skip the statements
// between #ifndef and #endif
because_THING_H_ will have
//
been previously #define'd.
#include <glut.h>
class Thing
{
public: // member function
prototypes
// Normal coding style convention is that public function
// member declarations are placed at the start of a header
// file.
Thing(); // default
constructor
Thing(int x); //
another constructor
void setSize(int
size);
void setColor(float r, float g, float b);
void draw();
private: // data member
declarations
// Normal coding style convention is that data member
// declarations are placed at the end of a header file.
int size:
float
color[3];
};
#endif _THING_H_
Thing::Thing()
{
// code for default
constructor
}
Thing::Thing(int x)
{
// code for another constructor
}
void Thing::setSize(int s)
{
// code for setSize
}
void Thing::setColor(float r, float g, float
b)
{
// code for setColor
}
void Thing::draw()
{
// code for draw
}