#ifndef DYNARR_H_INCLUDED #include "dynarr.h" #define DYNARR_H_INCLUDED #include <iostream>...
#ifndef DYNARR_H_INCLUDED #include "dynarr.h"
#define DYNARR_H_INCLUDED #include <iostream>
class dynArr using namespace std;
{
private: dynArr::dynArr()
int *data; {
int size; data = NULL;
public: size = 0;
dynArr(); }
dynArr(int); dynArr::dynArr(int s)
~dynArr(); {
void setValue(int, int); data = new int[s];
int getValue(int); size = s;
}; }
#endif // DYNARR_H_INCLUDED dynArr::~dynArr()
{
delete [] data;
}
int dynArr::getValue(int index)
{
//write the code
}
void dynArr::setValue(int index, int value)
{
//write the code
}
Using C++ modify the header and the source files. Add a member function void allocate(int s) which allows you to change the size of the array. Make sure that memory is not leaked.
Solved
COMPUTER SCIENCE
1 Answer
Huy Lê Minh
Login to view answer.