"Web Developer" <no****@hotmail.com> wrote in message news:<3f********@news.iprimus.com.au>...
I just like to add that the .h extension denotes a C header file, while the
.hpp extension denotes a C++ header file. Maybe someone can clarify this?.
This is convention, but you'll see a ton of headers with C++-only
constructs in .h files as well. There are also other conventions that
are less common; instead of .cpp sometimes .C (if you have a case
sensitive filesystem) or .cxx or even .c++ if your filesystem supports
that filename are used, and the corrosponding .H, .hxx, and .h++ are
also occasionally seen.
Side note: I assume a header file is like the import statement in Java?
They are somewhat similar, but there are significant differences.
import only pulls some names into scope, for instance with an import
javax.swing.* you'll only have to use the identifier JPanel instead of
javax.swing.JPanel. In this sense it's like a using statement. (I
chose "statement" to leave the exact meaning ambiguous; the above
import is like a using directive, while if i had said import
javax.swing.JPanel that's analogous to a using declaration.)
#include <filename> and #include "filename" actually put the contents
of filename into the current file. This is necessary because there is
(thankfully IMO) no way of knowing where the compiler (or VW in the
case of Java) should go to find things if I just write the following
C++ file:
int main () {
std::cout << "Hello mars!\n";
}
It doesn't know about the namespace std or the object std::cout.
Whereas if I write a similar Java program
class neededClass {
static int main() {
System.out.writeln("Hello mars!\n");
}
}
it knows where to find System, then System.out because of the standard
naming scheme.
Does that help?