iostream directive is not enough in VC++ for cout

The famous pain for VC++ learning is the cout using VC++. In other compilers cout only requires iostream.h header but unfortunately this does not work for VC++.

VC++ requires another statement using namespace std;

 

See the complete Hello word below.

 

#include “stdafx.h”

#include <iostream>

using namespace std;

 

int _tmain(int argc, _TCHAR* argv[])

{

       cout << “Hello world”;

       return 0;

}

About these ads

About chanmingman

Ming Man is a senior manager for a development company. With 20 years of experience in the IT field, he has developed system using Clipper, COBOL, VB5, VB6, VB.NET, Java and C #. He is familiar with the N-Tier design of business application and is also an expert with database experience in MS SQL, Oracle and AS 400.
This entry was posted in .Net and tagged , , . Bookmark the permalink.

One Response to iostream directive is not enough in VC++ for cout

  1. sanme98 says:

    Hi, beside using namespace std, we can use std::cout to solve the problem too.

    #include “stdafx.h”
    #include
    int _tmain(int argc, _TCHAR* argv[])
    {
    std::cout << “Hello world”;
    return 0;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s