template <typename T>
class bizobjectpool
{
private:
T *m_p;
public:
bizobjectpool();
};template<> bizobjectpool<T>::bizobjectpool()
{
m_p = new T();
}编译出错,提示error C2512: “T”: 没有合适的默认构造函数可用。另外我如果希望typename T都是从bizpooledobject类继承的,应该如何写?谢谢!
class bizobjectpool
{
private:
T *m_p;
public:
bizobjectpool();
};template<> bizobjectpool<T>::bizobjectpool()
{
m_p = new T();
}编译出错,提示error C2512: “T”: 没有合适的默认构造函数可用。另外我如果希望typename T都是从bizpooledobject类继承的,应该如何写?谢谢!
应该是:
bizobjectpool<T>::bizobjectpool()吧
改为 bizpooledobject *m_p;
class bizobjectpool
{
private:
T *m_p;
public:
bizobjectpool()
{
m_p = new T;
}
};