Article ID: 167966
Article Last Modified on 7/5/2005
#include <iostream>
//#define WORKAROUND //Uncomment this line for workaround
class A
{
protected:
A() { std::cout << "A()" << std::endl ;}
~A() { std::cout << "~A()" << std::endl ;};
friend A* GetA();
};
A* GetA()
{
#ifndef WORKAROUND
static A a ;
return &a ;
#else
static A *pA = new A;
return pA;
#endif
}
void main()
{
A *pA = GetA() ;
}
Keywords: kbbug kbfix kbnoupdate kbcode KB167966