Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to explicitly call destructor of a class in Turbo C++

I'm trying to call the destructor of a class explicitly in Turbo C++:

A a;
a.~A();

But it's showing an error:

Member identifier expected.

Is there any way to explicitly call a destructor in Turbo C++?

like image 643
Shreyas Avatar asked Dec 08 '22 12:12

Shreyas


1 Answers

From this link, it seems you actually can do it, the valid format is:

A a;
// a.~A(); // Wrong - Member identifier expected
a.A::~A(); // Valid

But I don't have a Turbo C++ compiler handy to test it, so you'll have to test it.

[Edit]

OP tested it, it works.

like image 139
sashoalm Avatar answered Jan 18 '23 02:01

sashoalm