I've created a vector of class Test
Vector<Test> Test_object
in which i create a random number of object and place them inside the vector.
I then append there arrays together using some functions, "merging 2 obj"
Which make the 2 second obj redundant, since it is already included in the first one..
thats why i want to free the memory of this object..
Hi! I think you got confused here in 'delete'. This keyword is used for deleting dynamically allocated objects. You dont use that to delete the class itself! The destructor is used to free memories like your
Test_object
for example, objects from inside your class. And btw, the destructor is automatically called everytime the object's scope has finished,(after a function{}), or the class is deleted(if it was used dynamically with 'new').
hmm.. how do i then remove redundant obj.
It take up too much memory..
The vector i've created consist of objects, and since i merge them with the first one, a lot of objects will be redundant, since their information can be found in the first object.
hmm...you could try this pseudocode:
///during merge
for(unsigned int i= 0;i<vector1.size();i++)
{
for(unsigned int j=0;j<vector2.size();j++)
{
if (vector1[i]==vector2[j])
vectormerged.erase(vector[1].size()+j);///depends on how you merged them