Understanding Namespace?
I just started learning C++, I plan on going to college and majoring in Computer Science. I just wanted to get a head start before I went. I keep hearing about using namespace std; , but I bought a book on C++ and it only touches on it. I want to understand what the purpose and format I should use it in.
Why is this needed and without it why cant the compiler compile the program?
I use to use a MSDN version of MSVC++ ( I have family in high places) and I never had to use namespace (remember I just started). So why is it different in Linux? Here I will give a quick example:
#include <iostream>
#include <stdlib.h>
#include <string>
void Printname(string first, string last);
int main(int argc , char *argv[])
{
Printname("Linus" , "Torvalds");
return 0;
}
void Printname(string first, string last)
{
String fullname = first + " " + last;
cout << fullname << endl;
}
Thanks
|