CHAPTER 10

image

Properties and Events

Annual income twenty pounds, annual expenditure nineteen nineteen six, result happiness. Annual income twenty pounds, annual expenditure twenty pound ought and six, result misery.

—Charles Dickens, David Copperfield

Properties were created to provide field-like functionality for data in a context that allows the programmer to either access the data or abstract the data in an entirely different fashion than is provided by the type system.

Normal fields are simple type declarations within a class. A property contains a method for retrieving data called a getter, a method for storing data called a setter, or both ...

Get C++ 2013 for C# Developers,Second 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.