Chapter 1. Getting Started

CONTENTS

Section 1.1 Writing a Simple C++ Program 2

Section 1.2 A First Look at Input/Output 5

Section 1.3 A Word About Comments 10

Section 1.4 Control Structures 11

Section 1.5 Introducing Classes 20

Section 1.6 The C++ Program 25

Chapter Summary 28

Defined Terms 28

This chapter introduces most of the basic elements of C++: built-in, library, and class types; variables; expressions; statements; and functions. Along the way, we’ll briefly explain how to compile and execute a program.

Having read this chapter and worked through the exercises, the reader should be able to write, compile, and execute simple programs. Subsequent chapters will explain in more detail the topics introduced here.

Learning a new programming ...

Get C++ Primer, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.