O'Reilly logo

Ivor Horton's Beginning Visual C++ 2013 by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2Data, Variables, and Calculations

  • C++ program structure
  • Namespaces
  • Variables in C++
  • Defining variables and constants
  • Basic input from the keyboard and output to the screen
  • Performing arithmetic calculations
  • Casting operands
  • Variable scope
  • What the auto keyword does
  • How to discover the type of an expression

You can find the wrox.com code downloads for this chapter on the Download Code tab at www.wrox.com/go/beginningvisualc. The code is in the Chapter 2 download and files are individually named according to the names throughout the chapter.

THE STRUCTURE OF A C++ PROGRAM

Console applications are programs that read data from the command line and output results to the command line. All the examples that you’ll write to understand how the C++ language works will be console programs. This avoids having to dig into the complexities of creating and managing Windows applications before you have enough knowledge of how they work. You will be able to focus entirely on C++. After you have mastered that, you’ll be ready to deal with creating and managing Windows applications and the sacks of code that it involves. I’ll start by explaining how console programs are structured.

A C++ program consists of one or more functions. A function is a self-contained block of code with a unique name that you use to identify the function when you want to execute it. Chapter 1 includes an example of a Win32 console ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required