liveBook · Manning

CookbookAttrs

As explained in Object-Oriented Software Design in C++

A book-specific class representing attributes and matching behavior specialized for cookbooks.

CookbookAttrs represents cookbook-specific attributes while reusing common title and author fields from Attributes. It adds a Region value for cookbook classification. section 2.3.3

Its design responsibilities include:

  • Accepting title, author surname, author given name, and region through its constructor. section 2.3.3
  • Using the inherited Attributes matching behavior before checking cookbook-specific data. section 2.3.3
  • Representing regions as CHINA, FRANCE, INDIA, ITALY, MEXICO, US, or UNSPECIFIED. section 2.3.3
  • Supporting polymorphic storage in Book and cookbook insertion and lookup through Catalogue. section 2.3.3

A cookbook entry

catalogue.add(new CookbookAttrs("The Woks of Life", "Leung", "Bill", Region::CHINA)); section 2.3.3

Listing 2.9 (Program 2.3 Books-3): Fiction.h
#include "Book.h"
#include "FictionAttrs.h"

using namespace std;

class Fiction : public Book                              #1
{
public:
    Fiction(FictionAttrs * const attrs) : Book(attrs) {} #2
};
#1 Class Fiction is a subclass of class Book.
#2 Call the constructor of superclass Book.

The related class listing shows the parallel Cookbook subclass that passes CookbookAttrs to its Book superclass. section 2.3.3

How Object-Oriented Software Design in C++ covers it

How deep it goes
Explains inheritance, region enumeration, and matching delegation, while exposing runtime type checks elsewhere in catalogue lookup.
Examples
Uses The Woks of Life by Bill Leung with Region::CHINA as a concrete construction example.
What it assumes
Assumes basic C++ classes, constructors, inheritance, enumerations, and polymorphic pointers.
What you can do after
Build cookbook records with shared bibliographic fields, a region enum, and catalogue insertion.
How it connects
Connects Attributes, Book, Cookbook, Catalogue, inheritance, and the Open-Closed Principle.

This explainer was generated by Manning's knowledge graph from the text of Object-Oriented Software Design in C++. The section links point to the parts of the book it draws on.