### Define a vector of pointers called pvector

Hello,

The following is the exercise no. 15.
https://s2.postimg.org/wyjwt43ll/image.png

Just like many other exercises it's not comprehensible well enough to me. I have this for that:
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178`` ``````#include #define pvector Vector using namespace std; template class My_allocator { public: T allocate(int n); // allocate space for n objects of type T void deallocate(T p, int n); // deallocate n objects of type T starting at p void construct(T p, const T& v); // construct a T with the value v in p void destroy(T p); // destroy the T in p }; //------------------------------------------------- template T My_allocator::allocate(int n) { T p = (T)malloc(sizeof(T)*n); return p; } //------------------------------ template void My_allocator::deallocate(T p, int n) { free(p); } //------------------------------ template void My_allocator::construct(T p, const T& v) { p = new (p) T(v); } //------------------------------ template void My_allocator::destroy(T p) { p->~T(); } //------------------------------------------------ class Range_error : out_of_range { public: int index; Range_error(int i) :out_of_range("Range error"), index(i) {} }; //-------------------------------------------------- template > class pvector { A alloc; int sz, space; T elem; public: pvector() :sz(0), space(0), elem(nullptr) {} pvector(int n) :sz(n), space(n) { elem = alloc.allocate(n); initial(); } pvector(int n, const T& v) :sz(n), space(n) { elem = alloc.allocate(n); initial(v); } pvector& operator=(const pvector); // Copy assignment // Copy constructor int size() const { return sz; } int capacity() const { return space; } void initial(); void resize(int, T); void push_back(const T&); void reserve(int); T& operator[](unsigned int n) // rather than return at(i); { if (n < 0 || this->sz <= n) throw Range_error(n); return elem[n]; } const T& operator[](unsigned int n) const { if (n < 0 || this->sz <= n) throw Range_error(n); return elem[n]; } ~pvector() { delete elem; } // Destructor }; //------------------------------------------------ template pvector& pvector::operator=(const pvector a) { if (a.size() <= space) { for (int i = 0; i < a.size(); ++i) elem[i] = a.elem[i]; sz = a.size(); return *this; } else if (a.size() > space) { T* p = alloc.allocate(a.size()); for (int i = 0; i < sz; ++i) alloc.construct(&p[i], a.elem[i]); for (int i = 0; i < sz; ++i) alloc.destroy(&elem[i]); alloc.deallocate(elem, space); elem = p; space = sz = a.size(); return *this; } } //--------------------------------------------- template void pvector::initial() { for (int i = 0; i < sz; ++i) elem[i] = 0; } //------------------------------------------- template void pvector::resize(int newsize, T val = T()) { reserve(newsize); for (int i = sz; i < newsize; ++i) alloc.construct(&elem[i], val); // construct for (int i = newsize; i < sz; ++i) alloc.destroy(&elem[i]); // destroy sz = newsize; } //-------------------------------------------- template void pvector::push_back(const T& val) { if (space == 0) reserve(8); else if (sz == space) reserve(2 * space); alloc.construct(&elem[sz], val); ++sz; } //-------------------------------------- template void pvector::reserve(int newalloc) { if (newalloc <= space) return; T* p = alloc.allocate(newalloc); for (int i = 0; i < sz; ++i) alloc.construct(&p[i], elem[i]); for (int i = 0; i < sz; ++i) alloc.destroy(&elem[i]); alloc.deallocate(elem, space); elem = p; space = newalloc; } //---------------------------------- int main() { int i = 5; int* pi = &i; pvector v1; v1.push_back(pi); *v1[0] = 10; cout << v1.size() << ' ' << v1.capacity() << ' ' << *v1[0] << ' ' << v1[0] << ' ' << endl; pvector v2(3); cout << v2.size() << ' ' << v2.capacity() << ' ' << *v2[0] << ' ' << v2[0] << ' ' << endl; system("pause"); return 0; }``````

I get the following error:

Severity Code Description Project File Line Suppression State Error C2440 'return': cannot convert from 'int' to 'int *&' test2 82