I've written a simple (and potentially bad) implementation for a vector class, similar to std::vector.
Here is the class:
template <class T>
class Vector
{
T* data;
int size;
public:
Vector(int = 0);
~Vector();
Vector(const Vector<T>&);
Vector<T>& operator=(Vector<T>);
T& operator[](int);
friend void swap(Vector<T>&, Vector<T>&);
void Clear();
void Insert(T, int);
void Delete(int);
int Size();
};
When debugging code that uses my vector, I've noticed that the pointer that I'm using internally only expands up to the first element normally.
I found this SO question, How to display a dynamically allocated array in the Visual Studio debugger?, which seems to give a simple solution to the problem, but I'm wondering if it's possible to expand the array by a non-constant amount (say, the current vector size).
Considering that std::vector does show all of its elements normally inside the debugger, could I alternatively rewrite my vector to include that functionality?
Here is a snip of the "Locals" tab with some test variables, to show what I'm referring to: