Hello everyone

I know that one cannot pass a parameter to destructor functions in classes.

Is there a reason why this functionality was left out of c++, and is there a way to get around it?

Thanks!

Sure, just set a member variable before your destructor gets called, and reference that variable from the destructor.

Dave

Thanks!

I never thought of that :)

Are you calling your destructor function explicitly? If so.. you probably shouldn't ;)

Well, what I meant was that if I created an object based on a class, with dynamic allocation, such as this:

Vehicle *a = new Vehicle;

then I would have to delete it later on, using delete
I was thinking if there is a way to pass parameters at the delete statement

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.