Question
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
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
//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 arrayStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started