Creating a Standard C++ Program (C+)
With Visual C++ 2008, you can create Standard C++ programs by using the Visual Studio development environment. By following the steps in this topic, you can create a project, add a new file to the project, modify the file to add C++ code, and then compile and run the program by using Visual Studio.
You can type your own C++ program or use one of the sample programs. The sample program that is used in this topic is a console application. The application uses the set container in the Standard Template Library (STL), which is part of the ISO C++ 98 standard.
Visual C++ complies with these standards:
ISO C 95
ISO C++ 98
Ecma C++/CLI 05
To enforce ANSI C++ and ANSI C compliance checking of your program, use the /Za compiler option. (The default option is /Ze, which allows Microsoft extensions to the standard.) For more information, see /Za, /Ze (Disable Language Extensions).
To complete this walkthrough, you must understand the fundamentals of the C++ language.
To create a project and add a source file
On the File menu, point to New, and then click Project.
Under Project types, expand Visual C++, and then select Win32. Under Templates, click Win32 Console Application.
Type a project name.
By default, the solution that contains the project has the same name as the new project, but you can type a different name. You can also type a different location for the project.
Click OK to create the project.
In the Win32 Application Wizard, click Application Settings to reveal options for Application type. Under Additional Options, select Empty Project and then click Finish.
To add a new source file to the project
In Solution Explorer, right-click the Source Files folder, point to Add, and then click New Item.
On the Visual Studio installed templates list, select C++ File (.cpp), type a file name, and then click Add.
The .cpp file appears in the Source Files folder in Solution Explorer and is automatically opened in the code editor.
Copy the sample program from set::find (STL Samples) by clicking the Copy Code link under Example, and then paste the code into the empty file in the editor.
You can also choose a different sample program, or type your own valid C++ program into the empty file.
If you use the suggested sample program, notice the using namespace std; directive. This directive enables the program to use cout and endl without requiring fully qualified names (std::cout and std::endl).
To build and examine the program
On the Build menu, click Build Solution.
The Output window displays information about the compilation progress, for example, the location of the build log and a message that states the build status.
On the Debug menu, click Start without Debugging.
If you used the sample program, a command window is displayed and shows whether certain integers are found in the set.
Revised example code build process.