Professional Documents
Culture Documents
In this article
By completing this walkthrough, you'll become familiar with many of the tools and dialog boxes
that you can use when you develop applications with Visual Studio. You'll create a simple "Hello,
World"style application while you learn more about working in the integrated development
environment IDE.
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 1/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
After you open Visual Studio, you can see the three basic parts of the IDE: tool windows, menus
and toolbars, and the main window space. Tool windows are docked on the left and right sides of
the app window, with Quick Launch, the menu bar, and the standard toolbar at the top. The center
of the application window contains the Start Page. When you open a solution or project, editors
and designers appear in this space. When you develop an application, you'll spend most of your
time in this central area.
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 2/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
2. In the Visual C++ category, choose the Win32 Console Application template, and then
name the project GreetingsConsoleApp .
Your dialog box may have different choices, depending on what you've installed. If you
don't see Visual C++ project templates, you need to go back to the installer and install a
C++ workload.
3. When the Win32 Application Wizard appears, choose the Finish button.
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 3/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
The GreetingsConsoleApp project and solution, with the basic files for a Win32 console
app, are created and automatically loaded into Solution Explorer. The
GreetingsConsoleApp.cpp file is opened in the code editor. The following items appear in
Solution Explorer:
1. In the GreetingsConsoleApp.cpp file, enter a blank line before the line return0; and +
Code Copy
cout<<"Hello\n";
A red squiggly line appears under cout . An error message appears if you point to it.
The error message also appears in the Error List window. You can display the window by
choosing View, Error List on the menu bar.
2. To include the iostream header, enter the following code after #include"stdafx.h" :
Code Copy
#include<iostream>
usingnamespacestd;
You probably noticed that a box appeared as you entered code, providing suggestions for
the characters that you entered. This box is part of C++ IntelliSense, which provides
coding prompts, including listing class or interface members and parameter information.
You can also use code snippets, which are predefined blocks of code. For more
information, see Using IntelliSense and Code Snippets.
The red squiggly line under cout disappears when you fix the error.
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 5/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 6/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
The debugger starts and runs the code. The console window a separate window that
looks like a command prompt appears for a few seconds but closes quickly when the
debugger stops running. To see the text, you need to set a breakpoint to stop program
execution.
To add a breakpoint
1. Add a breakpoint from the menu bar at the line return0; . You can also just click in the
left margin to set a breakpoint.
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 7/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
A red circle appears next to the line of code in the far left margin of the editor window.
The debugger starts, and a console window appears showing the word Hello.
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 8/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
1. From the menu bar, delete intermediate files and output files that were created during
previous builds.
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 9/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
See Also
Using the Visual Studio IDE for C++ Desktop Development
Walkthrough: Create a Simple Application with Visual C# or Visual Basic
Productivity Tips for Visual Studio
Visual Studio Samples
Get Started Developing with Visual Studio
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 10/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 11/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 12/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 13/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 14/15
17/5/2017 GettingStartedwithC++inVisualStudio| MicrosoftDocs
https://docs.microsoft.com/enus/visualstudio/ide/gettingstartedwithcppinvisualstudio 15/15
17/5/2017 UsingtheVisualStudioIDEforC++DesktopDevelopment| MicrosoftDocs
In this article
Prerequisites
Get Started
Next Steps
See Also
The Visual Studio Integrated Development Environment IDE offers a set of features that help you
manage large and small code projects, write and refactor your code, and detect and correct errors
by using both static analysis and powerful debugging tools. This set of articles is designed to walk
you through each step you'll need to manage your projects, write, test, and debug your code, and
then deploy it to another computer.
Prerequisites
If you haven't installed Visual Studio yet, now is the time. To get Visual Studio, you can download it 2
from Visual Studio Downloads. Be sure to include the Visual C++ development tools when you
install Visual Studio, because they are not installed by default. For more information about how to
install Visual Studio, see [].
These walkthroughs assume that you have installed Visual Studio and the Visual C++ language
and components required for Windows Desktop development. We also assume you understand
the fundamentals of the C++ language. If you need to learn C++, there are many books and web
resources available. One good place to start is the Get Started page of the Standard C++
Foundation website.
Once your Visual Studio installation is complete, you are ready to continue.
Get Started
To get started using the Visual Studio IDE to build C++ apps, work through each of these topics in
order. Each one builds on the work you completed in the previous topics:
Next Steps
Once you've completed these walkthroughs, you're ready to start building your own projects. For
more information and resources for Visual C++ development, see Visual C++ in Visual Studio.
See Also
Application Development in Visual Studio +
https://docs.microsoft.com/enus/cpp/ide/usingthevisualstudioideforcppdesktopdevelopment 2/5
17/5/2017 UsingtheVisualStudioIDEforC++DesktopDevelopment| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/usingthevisualstudioideforcppdesktopdevelopment 3/5
17/5/2017 UsingtheVisualStudioIDEforC++DesktopDevelopment| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/usingthevisualstudioideforcppdesktopdevelopment 4/5
17/5/2017 UsingtheVisualStudioIDEforC++DesktopDevelopment| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/usingthevisualstudioideforcppdesktopdevelopment 5/5
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
In this article
Prerequisites
Creating a Project
Organizing Projects and Files in a Solution
Adding a Source File
Building and Running a Project
Next Steps
See Also
Here's how to create a C++ project in Visual Studio, add code, and then build and run the project. +
The project in this walkthrough is a program that tracks how many players are playing different
card games.
In Visual Studio, work is organized in projects and solutions. A solution can contain more than one
projectfor example, a DLL and an executable that references that DLL. For more information, see
Solutions and Projects.
Prerequisites
To complete this walkthrough, you must understand the fundamentals of the C++ language.
Creating a Project
To create a project, first choose a projecttype template. For each project type, Visual Studio sets
compiler settings anddepending on the typegenerates starter code that you can modify later.
To create a project
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 1/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
2. In the left pane of the New Project dialog box, expand the Installed Templates node,
expand the Visual C++ node, and then select Win32.
3. In the list of installed templates in the center pane, select Win32 Console Application.
4. Enter a name for the project in the Name box. For this example, enter Game.
You can accept the default location in the Location dropdown list, enter a different
location, or choose the Browse button to browse to a directory where you want to save
the project.
When you create a project, Visual Studio puts the project in a solution. By default, the
solution has the same name as the project. You can change the name in the Solution
name box, but for this example, keep the default name.
5. On the Overview page of the Win32 Application Wizard, choose the Next button.
You now have a project, but it does not yet have source code files.
This part of the walkthrough shows how add a class to the project. When you add the class, Visual
Studio adds the corresponding .h and .cpp files. Next, you add a new source code file for the main
program that tests the class.
1. If Solution Explorer is not displayed, on the menu bar, choose View, Solution
Explorer.
2. In Solution Explorer, open the shortcut menu for the Header Files folder and then
choose Add, Class.
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 2/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
In the left pane of the Add Class dialog box, expand the Visual C++ node and select
C++, and then in the list of installed templates in the center pane, select C++ Class.
Choose the Add button.
3. In the Generic C++ Class Wizard, enter Cardgame in the Class name box. Don't
modify the default file names and settings. Choose the Finish button.
Add two private data members after the opening brace of the class definition.
C++ Copy
intplayers;
staticinttotalParticipants;
Modify the default constructor that Visual Studio generated. After the public:
access specifier, find the line that looks like this:
Cardgame(void);
C++ Copy
Cardgame(intplayers);
After the default destructor, add an inline declaration for a static int member
function named GetParticipants that takes no parameters and returns the
totalParticipants value.
C++ Copy
staticintGetParticipants(){returntotalParticipants;}
5. The Cardgame.h file should resemble this after you change it:
C++ Copy
#pragmaonce
classCardgame
{
intplayers;
staticinttotalParticipants;
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 3/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
public:
Cardgame(intplayers);
~Cardgame(void);
staticintGetParticipants(){returntotalParticipants;}
};
The line #pragmaonce tells the compiler to include the file only one time. For more
information, see once.
For information about other C++ keywords in this header file, see class, int, static, and
public.
6. Choose the Cardgame.cpp tab in the editing pane to open it for editing.
C++ Copy
#include"Cardgame.h"
#include<iostream>
usingnamespacestd;
intCardgame::totalParticipants=0;
Cardgame::Cardgame(intplayers)
:players(players)
{
totalParticipants+=players;
cout<<players<<"playershavestartedanewgame.Therearenow"
<<totalParticipants<<"playersintotal."<<endl;
}
Cardgame::~Cardgame()
{
}
Note
You can use autocompletion when you are entering code. For example, if you were entering
this code, you could enter pl or tot and then press Ctrl+Spacebar so that autocompletion
finishes entering players or totalParticipants for you.
Now, add a source code file for the main program that tests the class.
1. In Solution Explorer, open the shortcut menu for the Source Files folder and then
choose Add, New Item.
In the Add New Item dialog box, in the left pane, expand the Installed node, expand the
Visual C++ node, and then select Code. In the center pane, select C++ File .cpp.
2. Enter TestGames.cpp in the Name box, and then choose the Add button.
C++ Copy
//TestGames.cpp
#include"Cardgame.h"
#include<iostream>
usingnamespacestd;
voidPlayGames()
{
Cardgamebridge(4);
Cardgameblackjack(8);
Cardgamesolitaire(1);
Cardgamepoker(5);
}
intmain()
{
PlayGames();
return0;
}
Note
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 5/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
If you are using an Express edition that does not display a Build menu, on the menu bar,
choose Tools, Settings, Expert Settings to enable it.
Output from a build is displayed in the Output window. If your build is successful, the
output should resemble this:
Output Copy
1>Buildstarted:Project:Game,Configuration:DebugWin32
1>TestGames.cpp
1>Cardgame.cpp
1>GeneratingCode...
1>Game.vcxproj>c:\users\username\documents\visualstudio\Projects\Game\Debug\Game.ex
==========Build:1succeeded,0failed,0uptodate,0skipped==========
The Output window can show different steps, depending on the edition and the build
configuration, but if the project build succeeds, the last line should resemble the output
shown.
If your build did not succeed, compare your code to the code that is given in the earlier
steps.
2. To run the project, on the menu bar, choose Debug, Start Without Debugging. The
output should resemble this:
Output Copy
4playershavestartedanewgame.Therearenow4playersintotal.
8playershavestartedanewgame.Therearenow12playersintotal.
1playershavestartedanewgame.Therearenow13playersintotal.
5playershavestartedanewgame.Therearenow18playersintotal.
Next Steps
Previous: Using the Visual Studio IDE for C++ Desktop Development. Next:Walkthrough: Building
a Project C++.
See Also
Visual C++ Guided Tour
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 6/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 7/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 8/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 9/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 10/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 11/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 12/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 13/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 14/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 15/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 16/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 17/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 18/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 19/20
17/5/2017 Walkthrough:WorkingwithProjectsandSolutions(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughworkingwithprojectsandsolutionscpp 20/20
17/5/2017 Walkthrough:BuildingaProject(C++)| MicrosoftDocs
In this article
Prerequisites
Next Steps
See Also
In this walkthrough, you deliberately introduce a Visual C++ syntax error in your code to learn
what a compilation error looks like and how to fix it. When you compile the project, an error
message indicates what the problem is and where it occurred.
Prerequisites
This walkthrough assumes that you understand the fundamentals of the C++ language.
It also assumes that you have completed the earlier related walkthroughs that are listed
in Using the Visual Studio IDE for C++ Desktop Development.
1. In TestGames.cpp, delete the semicolon in the last line so that it resembles this: +
return0
3. A message in the Error List window indicates that there was an error in the building of
the project. The description looks something like this:
errorC2143:syntaxerror:missing';'before'}'
To view help information about this error, highlight it in the Error List window and then
choose the F1 key.
4. Add the semicolon back to the end of the line that has the syntax error:
return0;
https://docs.microsoft.com/enus/cpp/ide/walkthroughbuildingaprojectcpp 1/5
17/5/2017 Walkthrough:BuildingaProject(C++)| MicrosoftDocs
A message in the Output window indicates that the project compiled successfully.
Output Copy
1>Buildstarted:Project:Game,Configuration:DebugWin32
1>TestGames.cpp
1>Game.vcxproj>C:\Users\<username>\Documents\VisualStudio<version>\Projects\Game\D
==========Build:1succeeded,0failed,0uptodate,0skipped==========
Next Steps
Previous: Walkthrough: Working with Projects and Solutions C++ | Next:Walkthrough: Testing a
Project C++
See Also
Visual C++ Guided Tour
DELETE_PENDING_Building and Debugging
https://docs.microsoft.com/enus/cpp/ide/walkthroughbuildingaprojectcpp 2/5
17/5/2017 Walkthrough:BuildingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughbuildingaprojectcpp 3/5
17/5/2017 Walkthrough:BuildingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughbuildingaprojectcpp 4/5
17/5/2017 Walkthrough:BuildingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughbuildingaprojectcpp 5/5
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
In this article
Prerequisites
Next Steps
See Also
When you run a program in Debug mode, you can use breakpoints to pause the program to
examine the state of variables and objects.
In this walkthrough, you watch the value of a variable as the program runs and deduce why the
value is not what you expect.
Prerequisites
This walkthrough assumes that you understand the fundamentals of the C++ language.
It also assumes that you have completed the earlier related walkthroughs that are listed
in Using the Visual Studio IDE for C++ Desktop Development.
Cardgame.solitaire(1);
3. To set a breakpoint on that line, on the menu bar, choose Debug, Toggle Breakpoint, or
choose the F9 key. A red circle appears to the left of the line; it indicates that a breakpoint
is set. To remove a breakpoint, you can choose the menu command or the F9 key again.
If you're using a mouse, you can also set or remove a breakpoint by clicking in the left
margin.
4. On the menu bar, choose Debug, Start Debugging, or choose the F5 key.
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 1/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
When the program reaches the line that has the breakpoint, execution stops temporarily,
because your program is in Break mode. A yellow arrow to the left of a line of code
indicates that it is the next line to be executed.
5. To examine the value of the Cardgame::totalParticipants variable, move the pointer over
Cardgame and then move it over the expansion control at the left of the tooltip window.
The variable name totalParticipants and its value of 12 are displayed.
Open the shortcut menu for the Cardgame::totalParticipants variable and then choose
Add Watch to display that variable in the Watch 1 window. You can also select a
variable and drag it to the Watch 1 window.
6. To step to the next line of code, on the menu bar, choose Debug, Step Over, or choose
the F10 key.
7. Open the shortcut menu for the return0; statement and then choose Run to Cursor.
The yellow arrow to the left of the code points to the next statement to be executed.
9. To stop the program, on the menu bar, choose Debug, Stop Debugging, or choose the
Shift+F5 keyboard shortcut.
Next Steps
Previous: Walkthrough: Building a Project C++ | Next:Walkthrough: Debugging a Project C++
See Also
Visual C++ Guided Tour
DELETE_PENDING_Building and Debugging
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 2/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 3/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 4/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 5/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 6/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 7/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 8/9
17/5/2017 Walkthrough:TestingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughtestingaprojectcpp 9/9
17/5/2017 Walkthrough:DebuggingaProject(C++)| MicrosoftDocs
In this article
Prerequisites
Next Steps
See Also
In this walkthrough, you modify the program to fix the problem that you discovered when you
tested the project.
Prerequisites
This walkthrough assumes that you understand the fundamentals of the C++ language.
It also assumes that you have completed the earlier related walkthroughs that are listed
in Using the Visual Studio IDE for C++ Desktop Development.
1. To see what occurs when a Cardgame object is destroyed, view the destructor for the +
Cardgame class.
In the Class View window, expand the Game project tree and select the Cardgame class
to display the class members and methods.
Open the shortcut menu for the ~Cardgamevoid destructor and then choose Go To
Definition.
2. To decrease the totalParticipants when a Cardgame terminates, add the following code
between the opening and closing braces of the Cardgame::~Cardgame destructor.
C++ Copy
totalParticipants=players;
cout<<players<<"playershavefinishedtheirgame.Therearenow"
<<totalParticipants<<"playersintotal."<<endl;
https://docs.microsoft.com/enus/cpp/ide/walkthroughdebuggingaprojectcpp 1/7
17/5/2017 Walkthrough:DebuggingaProject(C++)| MicrosoftDocs
3. The Cardgame.cpp file should resemble this after you change it:
C++ Copy
#include"Cardgame.h"
#include<iostream>
usingnamespacestd;
intCardgame::totalParticipants=0;
Cardgame::Cardgame(intplayers)
:players(players)
{
totalParticipants+=players;
cout<<players<<"playershavestartedanewgame.Therearenow"
<<totalParticipants<<"playersintotal."<<endl;
}
Cardgame::~Cardgame()
{
totalParticipants=players;
cout<<players<<"playershavefinishedtheirgame.Therearenow"
<<totalParticipants<<"playersintotal."<<endl;
}
5. When the build completes, run it in Debug mode by choosing Debug, Start Debugging
on the menu bar, or by choosing the F5 key. The program pauses at the first breakpoint.
6. To step through the program, on the menu bar, choose Debug, Step Over, or choose the
F10 key.
Notice that after each Cardgame constructor executes, the value of totalParticipants
increases. When the PlayGames function returns, as each Cardgame instance goes out of
scope and is deleted and the destructor is called, totalParticipants decreases. Just
before the return statement is executed, totalParticipants equals 0.
7. Continue stepping through the program until it exits, or let it run by choosing Debug,
Run on the menu bar, or by choosing the F5 key.
Next Steps
Previous: Walkthrough: Testing a Project C++ | Next:Walkthrough: Deploying Your Program
C++
See Also
https://docs.microsoft.com/enus/cpp/ide/walkthroughdebuggingaprojectcpp 2/7
17/5/2017 Walkthrough:DebuggingaProject(C++)| MicrosoftDocs
See Also
Visual C++ Guided Tour
DELETE_PENDING_Building and Debugging
https://docs.microsoft.com/enus/cpp/ide/walkthroughdebuggingaprojectcpp 3/7
17/5/2017 Walkthrough:DebuggingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdebuggingaprojectcpp 4/7
17/5/2017 Walkthrough:DebuggingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdebuggingaprojectcpp 5/7
17/5/2017 Walkthrough:DebuggingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdebuggingaprojectcpp 6/7
17/5/2017 Walkthrough:DebuggingaProject(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdebuggingaprojectcpp 7/7
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
In this article
Prerequisites
Next Steps
See Also
Now that you've created your application by completing the earlier related walkthroughs, which
are listed in Using the Visual Studio IDE for C++ Desktop Development, the last step is to create an
installer so that other users can install the program on their computers. To do this, you'll add a new
project to your existing solution. The output of this new project is a setup.exe file that will install
your app on another computer.
This walkthrough shows how to use Windows Installer to deploy your application. You can also use
ClickOnce to deploy an application. For more information, see ClickOnce Deployment for Visual
C++ Applications. For more information about deployment in general, see Deploying Applications,
Services, and Components.
Prerequisites
This walkthrough assumes that you understand the fundamentals of the C++ language.
It also assumes that you have completed the earlier related walkthroughs that are listed
in Using the Visual Studio IDE for C++ Desktop Development.
If you havent already done so, download InstallShield Limited Edition ISLE, as described
in the steps later in this article. ISLE is free for Visual Studio developers and replaces the
functionality of the setup and deployment project templates in earlier editions of Visual
Studio.
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 1/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
1. When you are connected to the Internet, on the menu bar, choose File, New, Project to
open the New Project dialog box.
2. In the left pane of the dialog box, expand the Installed, Templates, and Other Project
Types nodes, and then select Setup and Deployment. In the center pane, select Enable
InstallShield Limited Edition and then choose the OK button.
3. Follow the instructions to install InstallShield Limited Edition for Visual Studio ISLE.
4. After you have downloaded, installed, and activated ISLE, close Visual Studio and reopen
it.
5. On the menu bar, choose File, Recent Projects and Solutions, and then choose the
Game solution to reopen it.
1. Change the active solution configuration to Release. On the menu bar, choose Build,
Configuration Manager. In the Configuration Manager dialog box, on the Active
solution configuration dropdown list, select Release. Choose the Close button to save
the configuration.
2. On the menu bar, choose File, New, Project to open the New Project dialog box.
3. In the left pane of the dialog box, expand the Installed, Templates, and Other Project
Types nodes, and then select Setup and Deployment. In the center pane, select
InstallShield Limited Edition Project.
4. Enter a name for the setup project in the Name box. For this example, enter Game
Installer. In the Solution dropdown list, select Add to solution. Choose the OK button
to create the setup project. A Project Assistant Game Installer tab opens in the editor
window.
5. At the bottom of the Project Assistant Game Installer tab, choose the Application
Information link.
6. On the Application Information page, specify your company name as you want it to
appear in the installer. You can use your own company name, or for this example, use
Contoso. Specify your application name; in this example, specify Game. Specify your
company web address, or for this example, use http://www.contoso.com.
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 2/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
7. At the bottom of the Project Assistant Game Installer tab, choose the Installation
Interview link.
9. In Solution Explorer, expand the Game Installer project, expand the Organize Your
Setup node, and then open the General Information page.
10. On the General Information Game Installer tab in the editor window, specify a Tag
Creator ID, for example, regid.201212.com.Contoso.
11. In Solution Explorer, under the Game Installer project, expand the Specify
Application Data node, and then open the Files page.
12. On the Files Game Installer tab in the editor window, under Source computers files,
open the shortcut menu for Primary Output From Game and choose Copy.
13. Open a shortcut menu in the space under the Name column in Destination computers
files, and choose Paste. A new item named Game.Primary Output appears.
14. In Solution Explorer, under the Specify Application Data node, open the
Redistributables page.
15. On the Redistributables Game Installer tab in the editor window, select the Visual
C++ 11.0 CRT x86 check box.
16. On the menu bar, choose Build, Build Solution to build the Game project and the Game
Installer project.
17. In the solution folder, locate the setup.exe program that was built from the Game Installer
project, and then run it to install the Game application on your computer. You can copy
this file to install the application and its required library files on another computer.
18. You can set many options in the setup project to suit your requirements. For more
information, in Solution Explorer, under the Game Installer project, open the Getting
Started page and then choose the F1 key to open the ISLE help library.
Next Steps
Previous: Walkthrough: Debugging a Project C++
See Also
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 3/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
See Also
Visual C++ Guided Tour
Deploying Desktop Applications
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 4/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 5/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 6/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 7/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 8/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 9/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 10/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 11/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 12/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 13/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 14/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 15/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 16/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 17/18
17/5/2017 Walkthrough:DeployingYourProgram(C++)| MicrosoftDocs
https://docs.microsoft.com/enus/cpp/ide/walkthroughdeployingyourprogramcpp 18/18