I have been programming for quite sometime in C++ but lately i realized i have been doing it all wrong. I used header files like iostream.h and non standard functions like getch or clrscr.
Now im trying to learn the actual thing and i can't understand a few differences.
1st is the different header file iostream. I have read its not a file at all but a method. I'm not understanding this statement very well.
2nd is the namespace std. Where is this namespace defined.
3rd If the classes and functions are defined inside the namespace std then why is the header files required.
1: <iostream> is a header, and also a class
2: the standard namespace (std) is defined in the standard headers
3: a header is a file containing the declarations of some stuff, a namespace is a language features used to separate symbols coming from different libraries
But the standard library is in the namespace std right.Are entire functions defined inside it.
Also i saw a program using the string class. it contained headers <iostream> and <string>. 'using namespace std' was used. Now if the std namespace is inside <iostream> class is it also inside the <string> class and are the two namespaces different. 'using namespace std' refers to which std ?
My questions might sound silly but im really very confused.
Each file uses namespace "std" { ... }. Since a namespace is just a name rather than a data type or structure or identifier, multiple files can use that namespace. There is no name clash because it is just a name.
I'm not sure if that explains it clearly enough, but I hope it helps a little.
Well probably I'm not asking the question right.
What i'm saying is whether inside every header file is there a namespace called std.
And is withing that namespace all the functions are defined.