I keep seeing people using this line in their code... I've never seen it til this forum... what does it do???
I keep seeing people using this line in their code... I've never seen it til this forum... what does it do???
<^>( * ; * )<^>
That's required in standard C++.
Pre-standard C++ your codes :
#include <iostream.h>
int main()
{
cout<<"Samples";
return 0;
}
but in standard C++ this is equivalent:
#include <iostream> // without extension .h
using namespace std; // for shorthand cout
int main()
{
cout<<"Samples";
// without line "using namespace std;", you must type this
// "std::cout<<"Samples";
return 0;
}
That's it !
Different libraries may contain identifiers of the same name but different scope. A namespace is used to define the scope of where identifiers and variables are placed. This feature helps prevent conflicts between different identifiers with the same name
You could use the namespace version:Code:#include <iostream.h> #include<string.h>
This is simply used to provide some sort of standard and help prevent possible compile errors if identifier overlapping occurs. The old method is still acceptable. Schools and many businesses, however, have made the change or are beginning to look in that direction.Code:#include <iostream> #include <cstring> using namespace std; // or call the individual functions needed using std::cout; using std::endl; using std::strcpy; // obviously this is more specific - some programmers prefer this rather // than the first method which would include the entire contents of // namespace. Another option is just to preceed all library function calls // with the scope identifier std::
David
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
Another method you can use to avoid bringing in the whole namespace but not have to write std::xxx all the time is:
Code:include <iostream> using std::cout; using std::cin; using std::endl; // etc, for whatever parts you use int main() { int x; cout << "Enter x: " << endl; cin >> x; . . . }