dynarr.h
#ifndef DYNARR_H_INCLUDED
#define DYNARR_H_INCLUDED
class dynArr { private: int *data;
int size;
public:
dynArr();
dynArr(int);
~dynArr();
void setValue(int, int);
int getValue(int); };
#endif // DYNARR_H_INCLUDED
dynarr.cpp
#include "dynarr.h"
#include <iostream>
#include using namespace std;
dynArr::dynArr() {
data = NULL;
size = 0; }
dynArr::dynArr(int s)
{ data = new int[s];
size = s; }
dynArr::~dynArr()
{ delete [] data;
}
int dynArr::getValue(int index)
{ return data[index];
}
void dynArr::setValue(int index, int value)
{
data[index] = value;
} ;
Tasks:
Task 1: In the driver file (main.cpp), perform the following sub-tasks:
1. Create two objects of this class, one with no constructor argument and one with the argument 5.
2. Take five input values from the user and store them in the array inside the second object using the set method.
3. For the second object, print all the values you just stored. Note that, you cannot assign anything in the first object since the array inside it has size 0. Neither can you change the size of this array to some other size.