Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <typename T>
- class SmartPtr{
- T *ptr;
- public:
- explicit SmartPtr(T *p=NULL){
- cout<<"Utworzono"<<endl;
- ptr = p;
- }
- ~SmartPtr(){
- cout<<"Usunieto"<<endl;
- delete(ptr);
- }
- T &operator *(){
- return *ptr;
- }
- T *operator ->(){
- return ptr;
- }
- };
- int main()
- {
- SmartPtr <double> ptr(new double());
- *ptr=10.02;
- cout<<*ptr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement