>>I know I can create a pointer array using the new keyword and can specify the size of the array during runtime. In this
>>case, how would I resize the array to add a new record or to delete an old one?
In C++ the preferred method for dynamic array is std::vector.
You should use std::vector
You can access a vector like you would a C style array.
std::vector
cout << vInt[0] << endl;
cout << vInt[1] << endl;
A vector will clean up the memory automatically, so you don't have to worry about calling new or delete.
Comment from Axter
Date: 07/12/2005 11:14AM PDT
Comment
To get the size of your vector, call the size() method
cout << "Qty items in array = " << vInt.size() << endl;
Comment from Axter
Date: 07/12/2005 11:17AM PDT
Comment
To create an array using a pointer, you use the following method:
int Qty = 99;
int *pArrayInt = new int[Qty];
Then you must make sure to use delete[] to clean up above variable:
delete [] pArrayInt;
There is not easy method to reallocate memory created via new[] operator.
That's why it's better to use a vector instead, which you can easily increase or decrease it's size.
Comment from Esulin
Date: 07/12/2005 12:02PM PDT
Author Comment
Ok... The following is my directory.h header file.
--------------------------------------------------------------------------------
#ifndef _directory_H
#define _directory_H
using namespace::std;
class directory
{
private:
std::vector