9.1 Introduction
This chapter takes a deeper look at classes. We use Time
, Date
and Employee
class case studies, and other examples, to demonstrate several class construction capabilities. We begin with a Time
class engineered to separate its interface from its implementation for reuse. The example also demonstrates using an include guard in a header to prevent header code from being included in the same source code file more than once, which typically results in compilation errors. In addition, class Time
uses an ostringstream
to create string
representations of the time in standard and universal time formats. We also explain the compilation and linking process from the standpoint of the class-implementation programmer, the client-code programmer ...
Get C++ How to Program, 10/e 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.