так верно ...
#include <iostream>
using namespace std;
template <class T>
class SmartPoint {
private:
T *object;
public:
SmartPoint(T *object) {
this->object = object;
}
T* operator->() {
return object;
}
T& operator*() {
return *object;
}
~SmartPoint() {
object->~T();
cout << "Destructor class Smart_ptr" << endl;
}
};
class A {
public:
int *m;
A(int s) {
m = new int;
}
~A() {
delete []m;
cout << "Destructor class A" << endl;
}
};
int main() {
{
SmartPoint<A> ptr(new A(5));
}
}
#include <iostream>
using namespace std;
template <class T>
class SmartPoint {
private:
T *object;
public:
SmartPoint(T *object) {
this->object = object;
}
T* operator->() {
return object;
}
T& operator*() {
return *object;
}
~SmartPoint() {
object->~T();
cout << "Destructor class Smart_ptr" << endl;
}
};
class A {
public:
int *m;
A(int s) {
m = new int
}
~A() {
delete []m;
cout << "Destructor class A" << endl;
}
};
int main() {
{
SmartPoint<A> ptr(new A(5));
}
}