考虑以下部分代码:
namespace Util {
template <class T>
class SimpleSingleton
{
public:
static T& getOne() {
if (instance == NULL)
instance = new T();
return *instance;
}
private:
static T* instance;
// ...
};
T *Singleton<T>::instance = NULL;
}
class A
{
friend class Util::Singleton<A>;
//...
private:
A() {};
//...
};
typedef Util::Singleton<A> SingletonA;
void main()
{
A a = SingletonA::Instance(); // c2248: 'A::A' : cannot access private member declared in class 'A'
}
我在这里做错了什么?