Sign in to follow this  
Narusegawa

Visual C++ (Visual Studio 2003)

Recommended Posts

A couple of things, please bear with me. I'm still new to C++ (although have experience with PHP/Delphi for years), I started with Dev-C++ and was going to focus on cross-platform. But this is a bit daunting I guess, so I've decided to go MSVC++ with DirectX and going to learn in this first as I primarily use Win32 systems anyway. I can work on cross-platform later on. Does anyone know of a good MSCV++ specific tutorial? For just simple programs. I've tried a tutorial that says to just start a new win32 console project, tell the app wizard to make the project empty, then add a new cpp file. I did this and entered some very basic code.
#include <iostream>

int main(void) {
  cout << "Hello World!";
  return 0;

}

This won't compile (I haven't got error message with me as I left that at home this morning). Yet this works fine with Dev-C++ and looks like perfectly valid c++ to me. If I go through the wizard and let it make the first few files it creates a file, very similar, and stdafx.h and stdafx.c (or something like that) which just contains iostream and tchars includes. The hello.c it makes contains pretty much the same code as above, yet this compiles. So if anyone does have a good tutorial on how to properly make a basic c++ program in MSVC++ it'd be much appreciated. Managed vs Unmanaged I've installed the DirectX9 SDK as I want to get into that eventually. However I keep seeing references to the above, unmanaged and managed. What IS the difference? I saw another thread which basically said it's just down to the way it compiles? I'd like to know what the difference is in terms of how you code? (Examples please?) P.S. If anyone wants to communicate over quicker medium I do have MSN at work. [Edit] I also forgot to ask, I've download the SDK Extras and Symbols etc too, for fullness. But they don't come with any documentation on how to install these into the SDK (DirectX). They just extract to folders. Anyone?
Fruny - edited source tag [Edited by - Fruny on October 15, 2004 4:42:48 AM]

Share this post


Link to post
Share on other sites
I tried your code with both, Visual C++ (2003) and Visual C++ 6.0

with the V6.0 it works perfectly without any warning or error.
But in the newer version (2003) it doesn't work complaining there is no such headerfile found.

Share this post


Link to post
Share on other sites
Like all standard library components, cout is located in the std namespace. Either do provide a fully qualified name:

#include <iostream>

int main(void) {
std::cout << "Hello World!";
return 0;
}


import the symbol into the global namespace with a using-declaration,

#include <iostream>

using std::cout;

int main(void) {
cout << "Hello World!";
return 0;
}


or import the entire std namespace into the global namespace with a using-directive.

#include <iostream>

using namespace std;

int main(void) {
cout << "Hello World!";
return 0;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this