nOOb trying to learn C++ with MS visual studio.

I'm reading some tutorials on C++ and I'm having problems right off the bat.

I'm just trying to make the first example in the book work:

#include <iostream.h>
int main()
{
cout << "Hello World!\n";
return 0;
}

But When I make a new project in MS Visual Studio, it automatically writes:

#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}


What the!!!??

If I delete it all and type the example in I can't compile. Can someone fill me in. Clearly I need to leave these lines in. But why!? why don't these tutorials say that? I must be missing something. Should I be trying a different compiler to learn with?
Start with a console application project. When given the choice, choose to use an empty project.

And get a newer tutorial. Preferably something newer than 1997.
The C++ video tutorials on xoax.net are really good. You can find them hosted on YouTube.

http://xoax.net/comp/cpp/

Start with the C++ Console tutorial.

http://xoax.net/comp/cpp/console/index.php

Alternatively, the tutorials here are very useful.
http://cplusplus.com/doc/tutorial/

One of the reasons your code won't compile, by the way, is because cout is part of a namespace called std, and outside of that namespace, it's undeclared. Here's a better explanation:
http://cplusplus.com/doc/tutorial/program_structure/

-Albatross
Last edited on
Thanks guys! especially for all these fantastic links. I am capable of searching, but I was definately looking at old info. I guess I'll chuck out these old books.
Topic archived. No new replies allowed.