I was studying smart pointers and based on this blog: link
#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;
}
But when compiling the same it returns this error:
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;