Estava estudando ponteiros inteligentes e com base neste blog: https://murilo.wordpress.com/2008/12/15/smart-pointers-os-ponteiros-espertos-do-c/
#include <iostream>
template <class T> class SmartPointer
{
T *ptr; public:
SmartPointer(T *p):ptr(p) {}
~SmartPointer() {delete ptr;}
T& operator*() {return *ptr;}
T* operator->() {return ptr;}
};
int main()
{
SmartPointer str(new std::string("Testando Smart Pointers"));
std::cout << *str << " size: " << str->size() << std::endl;
}
mas ao compilar o mesmo ele retorna este erro:
ex2.cxx: In function ‘int main()’: ex2.cxx:20:18: error: missing
template arguments before ‘str’
SmartPointer str(new std::string("Testando Smart Pointers"));
^~~ ex2.cxx:21:19: error: ‘str’ was not declared in this scope
std::cout << *str << " size: " << str->size() << std::endl;