This might seem like a question I shouldn't be asking, but I've seen different variations of #include. Sometimes you include .h and sometimes you don't. I've read recently that in C++ you don't put .h and in C you do. But in source code I look at and when I first tried a bit of C++ a few years ago (I stopped for years, I was working with Java, so I didn't keep up to date with C++), you'd have .h in #include. For example:
But when I look at some source code written pretty recently it has .h in it, but when I try to compile with .h it gives me an error. Why don't you put .h and when would be a time you do?Code:#include <iostream.h> // Now it's #include <iostream>
Also, I've seen #include written with <> or "". Usually when I see it written with quotes it's a user-created header file. Is that when you use it? And <> for built in header files? Like:
Or do they distinguish something else?Code:#include <iostream> #include "myHeaderFile"
And now you have to use namespaces like
I never had to do that. I'm guessing C++ has changed since the last time I used it? I know about namespaces, are they new, and C++ changed like that? Or where they always in the C++ language, you just never needed to define the namespace?Code:#include <iostream> using namespace std; // or instead of the using namespace line, // when calling a function like cout put the namespace name // in front like a class std::cout<<"Text";