Jul 14, 2018 at 6:05am
So I need an insert function that receives an unsigned long as a parameter and puts it into the next available spot. Is this right?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
class Numbers
{
public:
Numbers();
void insert(int item);
void resize();
void display();
Numbers(const Numbers & other);
void operator = (const Numbers& other);
private:
unsigned long * data;
std::size_t used;
std::size_t capacity;
};
Numbers::Numbers(){
used = 0; capacity = 5;
data = new int [capacity];
}
void Numbers::insert(int item){
if (used == capacity)resize();
data[used]=item;++used;
}
|
Last edited on Jul 14, 2018 at 6:07am
Jul 14, 2018 at 6:50am
Yes i think it should work now