Skip to Content
Introduction to Design Patterns in C++ with Qt, 2nd Edition
book

Introduction to Design Patterns in C++ with Qt, 2nd Edition

by Alan Ezust, Paul Ezust
September 2011
Intermediate to advanced
768 pages
15h 18m
English
Pearson
Content preview from Introduction to Design Patterns in C++ with Qt, 2nd Edition

Chapter 20: Scope and Storage Class

Identifiers have scope, objects have a storage class, and variables have both. In this chapter, we discuss the difference between declarations and definitions and how to determine the scope of identifiers and the storage class of objects.

20.1 Declarations and Definitions

Any identifier must be declared or defined before it is used. Declaring a name means telling the compiler what type to associate with that name.

Defining an object, or variable, means allocating space and (optionally) assigning an initial value. For example,

double x, y, z;char* p;int i = 0;QString message("Hello");

Defining a function means completely describing its behavior in a block of C++ statements. For example,

int max(int a, int b) ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

An Introduction to Design Patterns in C++ with Qt 4

An Introduction to Design Patterns in C++ with Qt 4

Alan Ezust, Paul Ezust
Programming with Qt, 2nd Edition

Programming with Qt, 2nd Edition

Matthias Kalle Dalheimer

Publisher Resources

ISBN: 9780132851619Purchase book