Could you please explain the differences between <> include format and the ".h" format? |
You're conflating two different things:
1) The difference between using
<>
and
""
in an include statement. The convention is that you use
<>
for including standard/third-party header files, and
""
for your own header files.
Some compilers (and other development tools) will treat these differently, e.g. giving warnings where appropriate in your own header files, but suppressing them in standard headers.
2) Whether or not a filename has a
.h
(or sometimes
.hpp
) extension. Basically, standard library headers don't, and all others (including ones you've written) do.
But isn't the m_scripttable object already defined at the same time it is declared. Doesn't the line
static std::vector<scriptptr> m_scripttable;
call the vector default constructor, consequently defining it? |
No. Static data members are not instantiated when an object of the class is instantiated (because they exist even when no objects of the class have been instantiated). The line:
static std::vector<scriptptr> m_scripttable;
is therefore considered to be a declaration only; it is still necessary to provide a definition of the entity somewhere in the code. Because the variable is defined once and once only (because that's the rule for any entity with external linkage), this is usually done in a .cpp file, and for class data members, it should be done in the .cpp file containing the class implementation.
The definition should look like this:
std::vector<cCmdLoader::scriptptr> cCmdLoader::m_scripttable;
Note that because this definition is outside the
class {};
block, you'll need to explicitly qualify both the name of the variable, and the
scriptptr type, with the name of the class they belong to.