Error C2065 Example 1: undeclared identifier

Description:

An undeclared identifier error, error C2065, implies that there is no declaration for the particular item. However, this example shows that the error can be caused by not having the proper scope. Specifically, this simple "Hello World" program omits the scope resolution of the standard namespace, std. As we can see, cout, endl, and cin are reported as undeclared identifiers, by the compiler.

Code with Errors:

Compiler Error Message:

1>------ Build started: Project: myproj, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\xoax.net\myproj\myproj\main.cpp(5): error C2065: 'cout' : undeclared identifier
1>c:\xoax.net\myproj\myproj\main.cpp(5): error C2065: 'endl' : undeclared identifier
1>c:\xoax.net\myproj\myproj\main.cpp(6): error C2065: 'cin' : undeclared identifier
1>c:\xoax.net\myproj\myproj\main.cpp(6): error C2228: left of '.get'
1>			must have class/struct/union
1>			type is ''unknown-type''
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Fixed Code:

Output:

C2065 Example 1 Output