Код: Выделить всё
class hardwareMonitor : public hardwareMonitor_
{
public:
// Overloaded getInstance methods to reflect original constructors
static std::shared_ptr getInstance();
void cleanup();
// Delete copy constructor and assignment operator
hardwareMonitor(const hardwareMonitor&) = delete;
hardwareMonitor& operator=(const hardwareMonitor&) = delete;
private:
// Private constructors to reflect the ones in hardwareMonitor_
hardwareMonitor() : hardwareMonitor_() {}
// Destructor
~hardwareMonitor() = default;
// Pointer to the single instance of the class
static std::shared_ptr instance;
};
Код: Выделить всё
std::shared_ptr hardwareMonitor::getInstance()
{
if (instance == nullptr)
{
instance = std::make_shared(new hardwareMonitor(), [](hardwareMonitor * p) { p->cleanup(); });
}
return instance;
}
void hardwareMonitor::cleanup()
{
delete this;
}
\include\xmemory(293,9): error C2248: ' hardwareMonitor::~hardwareMonitor': невозможно получить доступ к частному члену, объявленному в классе 'hardwareMonitor`
строке в xmemory:
Код: Выделить всё
_Obj.~_Ty();
Подробнее здесь: https://stackoverflow.com/questions/789 ... destructor