Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

VC++
VC++ Introduction
VC++ What's New
VC++ Supported Platforms
Visual C++ Settings
VC++ Breaking Changes
Visual C++ Walkthroughs
Visual C++ Editions
VC++ Project Templates
Visual C++ Guided Tour
VC++ Creating Command-Line Applications
VC++ Windows Applications
VC++ Reusable Code
VC++ Porting
VC++ Unix Users
VC++ Upgrade Wizard
VC++ Migration Primer
VC++ Managed Types
VC++ Member Declarations
VC++ Conversion Operators
VC++ Interface Member
VC++ Value Types
VC++ Boxed Value
VC++ General Language
VC++ Common Programming
VC++ Database Support
VC++ MFC Database Classes
VC++ Record
VC++ Record View
VC++ OLE DB Programming

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


Visual C++ Guided Tour


Previoushome Next






Visual C++ Guided Tour
In this guided tour you will learn about the Visual Studio development environment and about the various types of applications that you can create with Visual C++.
A D V E R T I S E M E N T
This includes command-line application, Windows applications, and even a simple game. This guided tour will also teach you how to create reusable libraries of code, and how to ship your code to customers after you have written and tested it.

Because each topic builds on information in the topics before it, we recommend that you complete the guided tour in order. At the bottom of each topic, you will find navigation links to the next topic in the guided tour, and a link to the previous topic if you want to go back and review something.

The guided tour assumes that you understand the fundamentals of the C++ language.




In This Section
Introducing the Visual Studio IDE (C++)
Describes how to use the Visual Studio IDE to create solutions and projects, to write code efficiently, and to build, debug, test, and deploy applications.
Creating Command-Line Applications (C++)
Introduces C and C++ command-line application, talks about how to create an ANSI conformant C or C++ program, and describes how to compile applications by using the command-line compilers.
Creating Windows Applications (C++)
Describes how to create Windows API (Win32) applications, Windows Forms applications, Windows Forms controls, and even a simple DirectX game.
Creating Reusable Code (C++)
Describes how to create dynamic link libraries (DLLs), static libraries, and managed assemblies so that code can easily be reused by multiple applications.
Where to Go Next (C++)
Contains links to other sections of the documentation where you can learn more about the topics that are introduced in the guided tour.
Introducing the Visual Studio IDE (C++)
The Visual Studio Integrated Development Environment (IDE) offers a set of tools that help you write and modify code, and also detect and correct errors.

In these topics, you create a new standard C++ program and test its functionality by using features available in Visual Studio for the C++ developer. The simple program you create will track how many players are playing different card games.

Introducing the Visual Studio IDE (C++)
The Visual Studio Integrated Development Environment (IDE) offers a set of tools that help you write and modify code, and also detect and correct errors.

In these topics, you create a new standard C++ program and test its functionality by using features available in Visual Studio for the C++ developer. The simple program you create will track how many players are playing different card games.

Projects and Solutions (C++)
In Visual Studio, you organize your work in projects and solutions. A solution can contain more than one project, such as a DLL and an executable that references that DLL. For more information, see Introduction to Solutions, Projects, and Items.



Prerequisites



Working with Projects and Solutions

The first step in writing a Visual C++ program with Visual Studio is to choose the type of project. For each project type, Visual Studio sets compiler settings and generates starter code for you.




To create a new project

  1. From the File menu, point to New, and then click Project….
  2. In the Project Types area, click Win32. Then, in the Visual Studio installed templates pane, click Win32 Console Application.
  3. Type a name for the project. In this example, we'll use game.

    When you create a new project, Visual Studio puts the project in a solution. Accept the default name for the solution, which is the same name as the project.

    You can accept the default location, type a different location, or browse to a directory where you want to save the project.

    Press OK to start the Win32 Application Wizard.

  4. On the Overview page of the Win32 Application Wizard dialog box, click Next.
  5. On the Application Settings page under Application type, select Console Application. Select the Empty Project setting under Additional options and click Finish.

    You now have a project without source code files.




Using Solution Explorer

Solution Explorer makes it easy for you to work with files and other resources in your solution.

In this step, you add a class to the project and Visual Studio adds the .h and .cpp files to your project. You then add a new source code file to the project for the main program that tests the class.




To add a class to a project

  1. If the Solution Explorer window is not visible, on the View menu click Solution Explorer.
  2. Right-click the Header Files folder in Solution Explorer and point to Add. Then click Class.

    In the Visual C++ category, click C++ and click C++ Class in the Visual Studio installed templates area. Click Add.

  3. In the Generic C++ Class Wizard, type Cardgame as the Class name and accept the default file names and settings. Then click Finish.
  4. Make these changes to the Cardgame.h file displayed in the editing area:
    • Add two private data members after the opening brace of the class definition:
      Copy Code
      int players;
      static int totalparticipants;
    • Add a public constructor prototype that takes one parameter of type int:
      Copy Code
      Cardgame(int p);
    • Delete the default constructor generated for you. A default constructor is a constructor that takes no arguments. The default constructor looks similar to the following:
      Copy Code
      Cardgame(void);
  5. The Cardgame.h file should resemble this after your changes:
    Copy Code
    #pragma once
    class Cardgame
    {
            int players;
            static int totalparticipants;
        public:
            Cardgame(int p);
            ~Cardgame(void);
    };

    The line #pragma once indicates that the file will be included only one time by the compiler. For more information, see once.

    For information about other C++ keywords included in this header file, see class (C++), int, Static (C++), and public (C++).

  6. Double-click Cardgame.cpp in the Source Files folder to open it for editing.
  7. Add the code for the constructor that takes one int argument:
    Copy Code
    Cardgame::Cardgame(int p)
    {
        players = p;
        totalparticipants += p;
        cout << p << " players have started a new game.  There are now "
             << totalparticipants << " players in total." << endl;
    }

    When you begin typing pl or to, you can press Ctrl-Spacebar and auto-completion will finish typing players or totalparticipants for you.

  8. Delete the default constructor that was generated for you:
    Copy Code
    Cardgame::Cardgame(void);
  9. The Cardgame.cpp file should resemble this after your changes:
    Copy Code
    #include "Cardgame.h"
    #include 
    using namespace std;
    
    Cardgame::Cardgame(int p)
    {
        players = p;
        totalparticipants += p;
        cout << p << " players have started a new game.  There are now "
             << totalparticipants << " players in total." << endl;
    }
    Cardgame::~Cardgame(void)
    {
    }

    For an explanation of #include, see The #include Directive.




Adding a Source File

In this step, you add a source code file for the main program that tests the class.




To add a new source file

  1. From the Project menu, click Add New Item.

    Alternatively, to use Solution Explorer to add a new file to the project, right-click the Source Files folder in Solution Explorer and point to Add. Then click New Item.

    In the Visual C++ area, select Code. Then click C++ File (.cpp).

  2. Type testgames as the Name and click Add.
  3. In the testgames.cpp editing window, type the following code:
    Copy Code
    #include "Cardgame.h"
    int Cardgame::totalparticipants = 0;
    int main()
    {
        Cardgame *bridge = 0;
        Cardgame *blackjack = 0;
        Cardgame *solitaire = 0;
        Cardgame *poker = 0;
    
        bridge = new Cardgame(4);
        blackjack = new Cardgame(8);
        solitaire = new Cardgame(1);
        delete blackjack;
        delete bridge;
        poker = new Cardgame(5);
        delete solitaire;
        delete poker;
    
        return 0;
    }

    For information about C++ keywords included in this source file, see new Operator (C++) and delete Operator (C++).

  4. On the Build menu, click Build Solution.

    You should see output from the build in the Output window indicating that the project compiled without errors. If not, compare your code to the code that appears earlier in the topic.

Building a Project (C++)
In this step, you deliberately introduce a Visual C++ syntax error in your code to see 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 topic assumes that you understand the fundamentals of the C++ language.




To fix compilation errors using the IDE

  1. In testgames.cpp, delete the semicolon in the last line so that it resembles this:
    Copy Code
    return 0
  2. On the Build menu, click Build Solution.
  3. A message in the Output window indicates that building the project failed.

    Click on the Go To Next Message button (the green, right-pointing arrow) in the Output window. The error message in the Output window and status bar area indicates there is a missing semicolon before the closing brace.

    To view more help information about an error, highlight the error and press the F1 key.

  4. Add the semicolon back to the end of the line with the syntax error:
    Copy Code
    return 0;
  5. On the Build menu, click Build Solution.

    A message in the Output window indicates that the project compiled correctly.

Testing a Project (C++)
Running a program in Debug mode enables you to use breakpoints to pause the program to examine the state of variables and objects.

In this step, you watch the value of a variable as the program runs and deduce why the value is not what you might expect.




Prerequisites

This topic assumes that you understand the fundamentals of the C++ language.




To run a program in Debug mode

  1. Click on the testgames.cpp tab in the editing area if that file is not visible.
  2. Set the current line in the editor by clicking the following line:
    Copy Code
    solitaire = new Cardgame(1);
  3. To set a breakpoint on that line, on the Debug menu, click Toggle Breakpoint, or press F9. Alternatively, you can click in the area to the left of a line of code to set or clear a breakpoint.

    A red circle appears to the left of a line with a breakpoint set.

  4. On the Debug menu, click Start Debugging or press F5.

    When the program reaches the line with 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 is the next line to be executed.

  5. To examine the value of the totalparticipants variable, hover over it with the mouse. The variable name and its value of 12 is displayed in a tooltip window.

    Right-click the totalparticipants variable and click Add Watch to display that variable in the Watch window. You can also select the variable and drag it to the Watch window.

  6. On the Debug menu, click Step Over or press F10 to step to the next line of code.

    The value of totalparticipants is now displayed as 13.

  7. Right-click the last line of the main method (return 0;) and click Run to Cursor. The yellow arrow to the left of the code points to the next statement to be executed.
  8. The totalparticipants number should decrease when a Cardgame terminates.At this point, totalparticipants should equal 0 because all Cardgame pointers have been deleted, but the Watch 1 window indicates totalparticipants equals 18.

    There is a bug in the code that you will detect and fix in the next section.

  9. On the Debug menu, click Stop Debugging orpress Shift-F5 to stop the program.

Deploying Your Program (C++)
Now that we've created our application, the last step is to create an installer that other users can use to install the program on their computer. To do this, we'll add a new project to our existing solution. The output of this new project is a setup.exe file that will install the application that we've previously created on another machine.

This walkthrough uses Windows Installer for deploying your application. You can also use ClickOnce to deploy an application. For more information, see ClickOnce Deployment. For more information on deployment in general, see Deploying Applications and Components.




Prerequisites

This topic assumes that you understand the fundamentals of the C++ language.




To create a setup project and install your program

  1. From the File menu, click Add, and then click New Project....

    The Add New Project dialog box appears.

  2. From the Project types: pane, expand the Other Project Types node and select Setup and Deployment.
  3. From the Templates pane, select Setup Wizard. Type a name for the setup project, such as gameInstaller, and click the OK button.
  4. The Setup Wizard will appear. Click Next to continue.
  5. From the Choose a project type pane of the wizard, select the Create a setup for a Windows application option and click Next to continue.
  6. From the Choose project outputs to include pane of the wizard, select Primary Output from game, and click Next to continue.
  7. We do not need to include any additional files in our installer, so from the Choose files to include pane of the installer, click Next.
  8. Review the changes from the wizard, and verify that everything is correct. Click Finish to create the project.

    The new gameInstaller project will be listed in the Solution Explorer. This project will list the dependencies that your application depends on (such as the C Runtime Library or the .NET Framework) as well as the project files that are to be included in the installer.

    There are many options that can be changed after the setup project has been created. For more information, see Windows Installer Deployment.

  9. Build the installer by selecting it in the Solution Explorer and clicking Build gameInstaller from the Build menu.
  10. Locate the setup.exe and gameInstaller.msi programs created by the previous section. Double click on either file to install the application on a computer.



Be the first one to comment on this page.




  VC++ eBooks

No eBooks on VC++ could be found as of now.

 
 VC++ FAQs
More Links » »
 
 VC++ Interview Questions
More Links » »
 
 VC++ Articles
More Links » »
 
 VC++ News
More Links » »
 
 VC++ Jobs
More Links » »

Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previoushome Next

Keywords: bsd programming language, bsd language programming tutorial pdf, history of bsd programming, basic bsd programming, bsd band satellite programming, syntax use in bsd programming, bsd programming software download, turbo bsd programming, bsd programming code, learn bsd programming

HTML Quizzes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizzes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizzes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizzes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizzes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizzes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building Quizzes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizzes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizzes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizzes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizzes
Oracle Quiz
MySQL Quiz
Operating System Quizzes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizzes
Testing Quiz
Firewalls Quiz
SAP Module Quizzes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizzes
Corba Quiz
Networking Quiz
Microsoft Office Quizzes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizzes
Financial Accounting Quiz
Managerial Accounting Quiz
Testimonials | Contact Us | Link to Us | Site Map
Copyright ? 2008. Academic Tutorials.com. All rights reserved Privacy Policies | About Us
Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | Discussions World | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Indian Free Ads | Jobs Assist | New Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Webhosting in India | Dedicated Server in India | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Testing Interview Questions | Tests World | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World | Important Websites
Copyright ? 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.