memory leak in assignment operator (using vectors)

Hey all - my set class uses two vectors, data<int> and child<set*>. I keep getting a heap leak inside the assignment operator. I've been back and forth over this multiple times. I can get more info if needed, but I'm stuck! Thanks so much.

1
2
3
4
5
6
7
8
9
10
11
12
13
void set::operator =(const set& source)
	{
		
		if (this == &source) return; //Checks for self-assignment
		
		clear();
		
		data = source.data;
		for (vector<set*>::size_type i = 0; i < source.child.size(); i++)
		{
			child.push_back(new set(*(source.child[i])));
		}
	}
Does set::clear() delete set::child[i]?
Yes -

1
2
3
4
5
 void set::clear( )
	{
		data.clear();
		child.clear();
	} 

My destructor just calls clear as well.
That doesn't delete each element.
1
2
for (size_t a=0;a<this->child.size();a++)
    delete this->child[a];
aha! worked like a charm. thanks muchly.
Topic archived. No new replies allowed.