O'Reilly logo

Sams Teach Yourself C++ in One Hour a Day, Sixth Edition by Bradley Jones, Siddhartha Rao, Jesse Liberty

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 15. An Introduction to Macros and Templates

By now, you should have a solid understanding of basic C++ syntax. Programs written in C++ should be understandable and you are poised to learn language features that help you write applications efficiently.

In this lesson, you will learn

  • An introduction to the preprocessor

  • The #define keyword and macros

  • An introduction to templates

  • Writing templates for functions and classes

  • The difference between macros and templates

The Preprocessor and the Compiler

Every time you compile a C++ file, the compiler first preprocesses it. This unit of the compiler that processes your code before it is actually compiled is called the preprocessor.

C++ features syntax elements by which the programmer can control the compile-time ...

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