#include <iostream>
#include <Windows.h>
#include <time.h>
#include <stdio.h>
using namespace std;
template<typename T>
class AutoPtr
{
public:
AutoPtr(T* pPtr)
{
m_Ptr = pPtr;
}
~AutoPtr()
{
printf("AutoPtr %d \n", *m_Ptr);
if(m_Ptr != NULL)
{
delete m_Ptr;
m_Ptr = NULL;
}
}
T* GetPtr()
{
return m_Ptr;
}
private:
T* m_Ptr;
};
void test()
{
int *a = new int();
*a = 4;
AutoPtr<int> autoPtrRank(a);
int& b = *a;
b = 5;
}
int main()
{
test();
system("pause");
return 0;
}