pointers

how to deallocate memory in C++

I have a class A where I construct an object of class B named bb. After constructing the object bb, I run in to a exception in Class A code which is caught by an exception handler. Now my question is how to deallocate the memory of object B in the exception handler? ...

Deleting pointers in a vector

Hi, I have a vector that I fill with pointers to objects. I am trying to learn good memory management. I have a few general questions: Is it true that when I am done with the vector I must loop through it and call delete on each pointer? Why don't I have to call delete on the vector (or any other variable I declare without the new stat...

Deleting a character from a string

Hi, I wanted to write a code that would delete a given character from a string. I have come up with the following snippet. Now, while this does my work, it is giving me a worst case complexity of O(n^2). Can anyone help me on improving this. #include<iostream.h> #include<conio.h> #include<stdio.h> void Push(char *, int i); int n=6;...

Error in a simple C code (pointers)

In the follwoing code, using libxml libraries : key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); if (flag == 1) { image2 = key; printf("the image 2 is %s \n", image2); flag = 2; } if(flag == 0...

Deletion of Custom Array Causes Heap Error.

TL;DR Boost-Test-Framework crashes with no error given while passing all tests and leaking all memory. Test fails multiple times with mentioned destructor implementations. Clear function also throws heap error. What are we doing wrong with the dtor? TL;DR This is pertaining to a college homework assignment, and my friend's solution ...