Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

main.cpp //This is the driver file. #include intlist.h int main() { IntList myList; myList.addNum(12); myList.addNum(23); myList.addNum(2); myList.addNum(38); myList.printList(); return 0; } intlist.cpp //This is the

image text in transcribed

main.cpp

//This is the driver file. #include "intlist.h"

int main() { IntList myList; myList.addNum(12); myList.addNum(23); myList.addNum(2); myList.addNum(38); myList.printList();

return 0; }

intlist.cpp

//This is the implementation file for IntList //See intlist.h for class details. #include "intlist.h"

//add all your function implementations here

intlist.h

//Class for a list of numbers //Implemented using dynamic int array

#pragma once #include using namespace std; //global constants const int CAP = 10;

//class definition for a list of numbers and its count class IntList { public: //To Do: constructor //To Do: destructor //To Do: getCount function //add and print functions private: int *list; int count; };

20.9 LAB: List of Integers (Pointers as data members in Classes) This program encapsulates a dynamic integer array and it's count in a class called IntList. The data members in the IntList class are: private: int list; int count; Given main(), complete the IntList class (in files intlist.h and intlist.cpp) with the following: - intlist.h - Prototypes for the following functions - Default constructor - Destructor - int getCount0 - to return the number of elements in the int array - void addNum(int) - takes a number and adds to the list of integers - void printList 0 - prints the list of numbers in the array - intlist.cpp - Write the definitions for the above functions. - Make sure the constructor allocates memory for the int array - Make sure the destructor deallocates the memory of the int array

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

Find y'. y= |x + X (x) (x) X 1 02x+ 2x 1 O 2x + 1/3 Ex 2x +

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago