Skip to main content

Decorator

  • Chapter
  • First Online:
  • 4194 Accesses

Abstract

Suppose you’re working with a class your colleague wrote, and you want to extend that class’ functionality. How would you do it, without modifying the original code? Well, one approach is inheritance: you make a derived class, add the functionality you need, maybe even override something, and you’re good to go.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    The Null Object is described in Chapter Chapter 19 of this book. Essentially, a Null Object is an object that conforms to some interface, but has empty methods, that is, methods that do absolutely nothing. This solves the problem when you must supply an object into an API, but you don’t want that object to actually do anything.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Dmitri Nesteruk

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Nesteruk, D. (2018). Decorator. In: Design Patterns in Modern C++. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3603-1_9

Download citation

Publish with us

Policies and ethics