What is this creation of an object: SmartPointer sp?

Write the code on the video lesson, the class smart pointers. Don't know what your definition of object is: SmartPointer<foo> sp(new Foo(2,2));</foo> why are <> brackets?
And yet, as the pointer can be void std::ptrdiff_t operator -(void *p) is that a reference to anything?
Please explain the value <> brackets.
Here is the code:
#include <iostream>

template <class type>

class SmartPointer {
 Type* pointer;
public:
 SmartPointer(Type* p) : pointer(p) {};
 operator Type*() { return pointer; };
 Type *operator->() { 
 if (!pointer) {
 pointer = new Type();
 std::cerr << "Bad Ponter!" << std::endl;
}
 return pointer; 
};
 std::ptrdiff_t operator -(SmartPointer<type> p) {
 return pointer - p;
}
 std::ptrdiff_t operator -(void *p) {
 return pointer - p;
}
};

class Foo {
 int a, b;
public:
 Foo() : a(0), b(0) {};
 Foo(int a, int b) : a(a) b(b) {};
 int sum() { return a + b; }

};

int main(int argc, char **argv) {
 SmartPointer<foo> sp(new Foo(2,2));
 std::cout << sp->sum() << std::endl;
system("pause>>void");
}</foo></type></class></iostream>
July 8th 19 at 11:49
3 answers
July 8th 19 at 11:51
Solution
There are types(classes)-"generics", their functionality depends on the type of template, for example, class Array<t></t>, where T is any type, for example, Array<int></int> - it will be an array of int s, Array<std::string></std::string> - array of std::string's, etc., in this case, the class SmartPointer<foo> sp;</foo> implements a "smart pointer" type Foo* sp;

And yet, as the pointer can be void std::ptrdiff_t operator -(void *p) is that a reference to anything?

void* - a "universal" pointer type, it is possible to cast a pointer of any type as well as int, where int is the number - address (number cells) in memory that contains data that you specify.
On 64 bit machines cast the pointer to int is incorrect, because pointer is 64 bit and int 32. - sister58 commented on July 8th 19 at 11:54
if the pointer is of type void is universal, then why can't I write: std::string s="1234"; void *sp=&s;? - carolanne_Boyer45 commented on July 8th 19 at 11:57
: Casts need implicit casts in C/C++ does not happen at all. - mazie.Towne commented on July 8th 19 at 12:00
: Not on 64-bit machines and in 64-bit programs. - mazie.Towne commented on July 8th 19 at 12:03
: fair enough. - sister58 commented on July 8th 19 at 12:06
: And if memory I only have 512 MB RAM (less than 4GB), the address will not be more than 32-bit int. - mazie.Towne commented on July 8th 19 at 12:09
: this is the physical address will be within. The same may well go beyond. - sister58 commented on July 8th 19 at 12:12
July 8th 19 at 11:53
Angle brackets indicate parameters of the template.
Templates told from the first pages of any book for dummies.
July 8th 19 at 11:55
Smart pointers are done with template classes, so read it, what are the templates: microsin.net/programming/pc/an-idiots-guide-to-cpp...

Find more questions by tags ProgrammingC++OOP