Walkthrough: Creating a Standard C++ Program (C++)
For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
You can use Visual C++ in the Visual Studio integrated development environment (IDE) to create Standard C++ programs. By following the steps in this walkthrough, 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 in this walkthrough is a console application. This application uses the
set container in the Standard Template Library (STL).
Visual C++ complies with the 2003 C++ Standard, with these major exceptions: two-stage name lookup, exception specifications, and export. Additionally, Visual C++ supports several C++0x features, for example, lambdas, auto, static_assert, rvalue references, and extern templates.
If compliance with the standard is required, use the /Za compiler option to disable 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.
Create a project by pointing to New on the File menu, and then clicking Project.
In the Visual C++ project types pane, click Win32, and then click Win32 Console Application.
Type a name for the project.
By default, the solution that contains the project has the same name as the 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 Next, select Empty Project,and then click Finish.
If Solution Explorer is not displayed, on the View menu, click Solution Explorer.
Add a new source file to the project, as follows.
In Solution Explorer, right-click the Source Files folder, point to Add, and then click New Item.
In the Code node, click C++ File (.cpp), type a name for the file, and then click Add.
The .cpp file appears in the Source Files folder in Solution Explorer, and the file is opened in the Visual Studio editor.
In the file in the editor, type a valid C++ program that uses the Standard C++ Library, or copy one of the sample programs and paste it in the file.
For example, you can use the set::find sample program, which is one of the the Standard Template Library samples that are included in Help.
If you use the sample program, notice the
using namespace std;directive. This directive enables the program to use
endlwithout requiring fully qualified names (
Save the file.
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 indicates 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.