Quote:
Originally Posted by Rekna
Code:
Class DynamicArray
{
public:
DynamicArray(int size);
~DynamicArray();
private:
char *A;
int N;
};
DynamicArray::DynamicArray(int size)
{
N=size;
A=new int[N];
}
DynamicArray::~DynamicArray()
{
delete A;
}
I havn't compiled this or anything so there may be a few typos but you should get the basic idea.
Then just add what ever functionality you want.
|
The only small change to this implementation is that technically, it should be:
Also - assuming you are willing to get into STL and use templates, I would recommend it. They have variable length strings, vectors, lists, iterators, etc. It does require a bit of understanding of the theory of C++ and object oriented programming, though.
A good reference:
http://www.sgi.com/tech/stl