+ 1

Why does the compiler revive a deleted object?

I'm trying to create a program where it makes sure that there is only one instance of the "Clock" class. The constructor of the "unwanted" object will call the destructor method. Basically an object suicide. But it didn't work out. Why? https://code.sololearn.com/cg6CKSgoqoTE/?ref=app

20th Jul 2021, 8:10 AM
Purple Requiem
Purple Requiem - avatar
3 Respostas
+ 2
20th Jul 2021, 8:19 AM
Ipang
+ 2
There are two problems: 1.Clock::getInstance() returns Clock* but bob is a Clock so add an star before bob. 2.bob will be a Clock* and dot operator should replace with arrow(->)
20th Jul 2021, 9:04 AM
GHOST mHBr
GHOST mHBr - avatar
0
GHOST mHBr thanks
20th Jul 2021, 9:05 AM
Purple Requiem
Purple Requiem - avatar