2 ms·
Eh... kind of? I guess it depends on your definition of "valid". Let's say we have: class Thing { public: Thing() { cout << "created" << endl; }
by cgrealy 6y ago
Eh... kind of?
I guess it depends on your definition of "valid".
Let's say we have:
class Thing
{
public:
Thing() { cout << "created" << endl; }
~Thing() { cout << "destroyed" << endl; }
};
Assuming the happy path, the new/delete version will be functionally identical to a more correct/idiomatic
{
auto thing = make_unique<Thing>();
}
The malloc/free version won't call the destructor, and therefore doesn't do what a "normal" object would do.
It's splitting hairs, I guess, but that's where I'd draw the line.