|
// testsmart.cpp : �������̨Ӧ�ó������ڵ㡣
//
#include "stdafx.h"
struct A
{
A()
{
printf("A()\n");
}
virtual ~A()
{
printf("~A()\n");
}
};
struct B: A
{
B()
{
printf("B()\n");
}
virtual ~B()
{
printf("~B()\n");
}
};
Single<A*>::Ref g_pA;
int _tmain(int argc, _TCHAR* argv[])
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF); //auto detect memory leak
Single<A*>::Ref pB = SingleAlloc<B>(); //ref new B
g_pA = pB; //auto InterlockedIncrement(ref-counter)
Array<A*>::Ref pAs = ArrayAlloc<A>(4); //ref new A[4]
SingleAligned<A*>::Ref pA_aligned = SingleAllocAligned<A>(16); //16 bytes aligned
ArrayAligned<A*>::Ref pAs_aligned = ArrayAllocAligned<B>(5, 16); //16 bytes aligned array(5 elements)
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.