Thread Hello World: Meine ersten Gehversuche (24 answers)
Opened by format_c at 2003-09-09 23:51

esskar
 2003-09-10 03:08
#11139 #11139
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=format_c,09.09.2003, 23:10]Ich geh grad son Tutorial für anfänger durch.
Da steht dann so was wie:
Code: (dl )
1
2
3
4
5
#include <iostream>
void main()
{
cout << "Hello World!";
};

Aber der g++ sagt da nur:
Code: (dl )
1
2
3
4
5
#include <iostream>
void main()
{
cout << "Hello World!";
};

dazu.

Unter Windows hat das funktioniert aber jetzt unter Linux irgendwie nicht.
Was die Ursache?

Gruß Alex[/quote]
das includefile iostream, das du benutzt, ist bestandteil der STL (Standard Template Library);
iostream enthält einen namespace (was namespaces genau sind, kannst du in jedem guten c++ buch nachlesen) names std;

mit

Code: (dl )
using namespace std;


sagst du dem compiler explizit, dass er nach funktionen auch im namespace std suchen soll
wenn du das nicht explizit möchtest, geht es auch so

Code: (dl )
1
2
3
4
5
#include <iostream>
void main()
{
std::cout << "Hello World!";
};


was anders ist das includefile iostream.h
dieses gehört zur standard c++ lib

damit würde dein code so aussehen

Code: (dl )
1
2
3
4
5
#include <iostream.h>
void main()
{
cout << "Hello World!";
};

View full thread Hello World: Meine ersten Gehversuche