I am making my first (semi-)usefull application: my own vector class :P I'm having some troubles with pointers: when I delete them in the destructor, I get a memory leak when I run the program (Something like: "glibc detected blabal double free or corruption" and then a lot of memory addresses) If I don't delete the pointers in the destructor, everything runs fine. I am sure I don't delete somewhere else.
Here's the class declaration:
And then I have a second question: if you have a class, you can declerate some variables outside public/private/protected. What I know you can't access the variables by myObj.value, but is it protected, private or something else?Code:template <class T> class myVec { T *arrPtr; T *temp; int count; public: myVec(int numElements); myVec(); ~myVec(); void addOnTop(T value); void addBegin(T value); void erase(int index); int size() { return count; } bool isEmpty(); T& operator=(const myVec &a); T& operator[](int index) {if(index > (count-1)) { cout << "Memory overload!!"; } else { return arrPtr[index]; } } };



LinkBack URL
About LinkBacks


