Template Class DerivedClass

Inheritance Relationships

Base Type

Template Parameter Order

  1. typename T

  2. unsigned int N

Class Documentation

template<typename T, unsigned int N>
class DerivedClass : public arbitrary::BaseClass

A derivation class of BaseClass serving as an extremely rudimentary array wrapper.

Template Parameters
  • T: The type of data we are storing.

  • N: The number of T data we are storing.

Public Types

typedef T SuperParent

A typedef to see what happens in the hierarchy.

Public Functions

DerivedClass()

Initializes the BaseClass field BaseClass::some_data to be the template parameter N.

virtual ~DerivedClass()

The default destructor; does nothing.

void virtualMethod()

Advances the printing index of this DerivedClass.

Prints a message to the console indicating what current_index is, and then increases current_index by one, wrapping around to 0 if current_index >= N.

bool insertAt(T &item, unsigned int index)

Inserts item and index if it is a valid item to add, and a valid index.

A valid index is in the range [0, N) where N is the second template parameter of the class. A valid index is also, for some arbitrary reason, one that has not already been set by a previous call. A valid item is anything that is not still nullptr from the constructor initialization.

Return

Whether or not this DerivedClass had it’s internal storage modified.

Parameters
  • item: The next item you want to store.

  • index: The index you would like to store item at.

const T &itemAt(unsigned int index)

Retrieve a pointer to the item at the specified index.

Return

The item at the specified index.

Parameters
  • index: The index of the item you want to retrieve a pointer to.

Exceptions
  • std::runtime_error: If the index is greater than N.

Protected Attributes

template<>
T items[N]

The internal storage of all the items.

unsigned int current_index = 0

The current printing index.