TemperatureList Class with Dynamic Array

TemperatureList Class with Dynamic Array.

I need help with a C Programming question. All explanations and answers will be used to help me learn.


In your textbook’s display 11-10, TemperatureList class was discussed. You will implement that same class using dynamic array in this lab. The original TemperatureList class implementation is given to you for reference.

This is the interface of the original class:

class TemperatureList
TemperatureList( );
//Initializes the object to an empty list.

void add_temperature(double temperature);
//Precondition: The list is not full.
//Postcondition: The temperature has been added to the list.

bool full( ) const;
//Returns true if the list is full; false otherwise.

friend ostream& operator <<(ostream& outs, const TemperatureList& the_object);
//Overloads the << operator so it can be used to output values of
//type TemperatureList. Temperatures are output one per line.
//Precondition: If outs is a file output stream, then outs
//has already been connected to a file.

double list[MAX_LIST_SIZE]; //of temperatures in Fahrenheit
int size; //number of array positions filled


Your job is to:

  1. Replace the array list[MAX_LIST_SIZE] with a dynamic array
  2. Add a max_size member variable that sets the max number of elements allowed in the array
  3. Add a constructor that accepts an integer parameter that specifies max_size
  4. Add the big three
  5. Change the implementation of the class to make sure no memory leak happens and the class functions as expected
  6. Separate the class into templist.h and templist.cpp files
  7. Follow the ADT (Abstract Data Type) guideline to implement the required class
  8. Comment well in your program and any functions you use


  1. In summary, you will have 8 member functions in your class:
    1. Default constructor
    2. Constructor that accepts an integer parameter to set the max_size
    3. Copy constructor
    4. Destructor
    5. Overload = operator
    6. add_temperature
    7. full (no change in its implementation)
    8. Overloading operator << (nothing shall need to change in its implementation)
  2. You will have 3 member variables in your class
    1. size – current size of your array
    2. max_size – max size the array will hold
    3. list – dynamic array/pointer to
  3. Starting from scratch might be easier for you than editing the original TemperatureList class.
  4. Watch video 12-2 for a discussion of TemperatureList implemented with a normal array.
  5. Watch the demos (videos 12-3 to 12-6) on List class in your lecture videos for how to implement the big three.
  6. Your TemperatureList class will be tested against other programs that use your class.


  1. Download the main.cpp as a starter test program. Feel free to edit it.
  2. Download the original TemperatureList class for reference.


Running your class with the given main.cpp will produce the following output:

23.5 F
24.6 F
23.5 F
24.6 F
Now there's no temperatures in a.
How about temperatures in b?
23.5 F
24.6 F

How to Run the Project

Create a new project in your IDE. Copy the content of the downloaded main.cpp to your new project. Add two files in your project (note you will need to tell your IDE the type of file you are adding).

  1. templist.h
  2. templist.cpp

Run the project as usual.

TemperatureList Class with Dynamic Array

Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount

Posted in Uncategorized