Alex Rivera | Logout

Destructor C++: type '***' argument given to 'delete', expected pointer

Asked 2008-12-20T02:58:22.630
16

I declared a private variable

vector<SomeClass> theVector;

someplace inside my SomeClass class.

Why can't I say: delete theVector inside my SomeClass destructor?

The compiler error says:

 type `class Vector<SomeClass>' argument given to `delete', expected pointer 

What expected pointer?

Edit
Report

1 Answer

2

To destroy all of the objects held in the vector, you would do the following:

theVector.resize(0);

This will happen automatically when the vector goes out of scope.

answered 2009-01-12T02:10:23.850

Your Answer