Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does'nt this compile?

From 'Accelerated C++', I've entered the following into my Visual C++.Net
editor:

#include

int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}

and get these error messages when compiling:

d:\C++Work\accelc-1\accelc-1.cpp(16): error C2065: 'endl' : undeclared
identifier
d:\C++Work\accelc-1\accelc-1.cpp(16): error C2065: 'cout' : undeclared
identifier
d:\C++Work\accelc-1\accelc-1.cpp(16): error C2296: '<<' : illegal, left
operand has type ''unknown-type''
d:\C++Work\accelc-1\accelc-1.cpp(16): error C2297: '<<' : illegal, right
operand has type 'char [15]'

A very simple program that I can't debug.
0 Kudos
Message 1 of 3
(2,715 Views)
How did you create the project? Try this:


  1. In Visual C++ .NET, go to File->New->Project ...

  2. In the Project Types list on the left, select Visual C++ Projects.

  3. In the Templates list on the right, select Win32 Project

  4. Enter a name for the project and hit OK.

  5. Click Application Settings on the left in the wizard, select Console application in the Application Settings, then click Finish.

  6. Change the main cpp file such that it has #include "stdafx.h" at the top, then has the sample code that you posted following it.

  7. Compile and run.



I tried these steps in a test project on my machine and it compiled and ran fine. I'm guessing that it's something with your project settings.


- Elton
0 Kudos
Message 2 of 3
(2,715 Views)
Thanks. You're right. I was using the 'Managed C++ Application' template.

"Elton Wells" wrote in message
news:5065000000050000003BD30000-1042324653000@exchange.ni.com...
> How did you create the project? Try this:
>
>

    >
  1. In Visual C++ .NET, go to File->New->Project ...

  2. >
  3. In the Project Types list on the left, select Visual C++
    > Projects.

  4. >
  5. In the Templates list on the right, select Win32 Project

  6. >
  7. Enter a name for the project and hit OK.

  8. >
  9. Click Application Settings on the left in the wizard, select
    > Console application in the Application Settings, then click
    > Finish.

  10. >
  11. Change the main cpp file such that it has #include "stdafx.h" at
    > the top, then has the sample code that you post
    ed following it.

  12. >
  13. Compile and run.

  14. >

>
> I tried these steps in a test project on my machine and it compiled
> and ran fine. I'm guessing that it's something with your project
> settings.
>
> - Elton
0 Kudos
Message 3 of 3
(2,715 Views)