#include <header>
or
#include "local file"
just (almost) copy and pastes the text from one file into that spot. That's all it does. By convention programmers code classes in separate files, or put classes, functions, and globals together (in the same file) that would be used together; like, <iostream> has
std::cout
,
std::cin
, and
std::cerr
all defined in the same file.
As for writing a class, create a text file and name it the name of the class you wish to create, with an optional .h or .hpp extension (but really you don't
need any specific extension; look at <iostream>, no .h there, just a name.) Then in this file type the following to get started:
1 2 3 4 5 6 7 8
|
#ifndef CLASSNAME_H_OR_FILENAME_EXTENSION_IN_CAPS
#define CLASSNAME_H_OR_FILENAME_EXTENSION_IN_CAPS
class ClassName {
//class stuff here...
};
#endif
|
Those prepossessor directives are known as header guards. Basically it says include this file's text, if and only if the file has not been included already. You want them on all your headers. They are the conventionally the classname_h (in caps) as they all must be unique.
For writing the class itself check this tutorial:
http://cplusplus.com/doc/tutorial/classes