The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


Copying Vectors

There is one more constructor for pvectors, which is called a copy constructor because it takes one pvector as an argument and creates a new vector that is the same size, with the same elements.

  pvector<int> copy (count);

Although this syntax is legal, it is almost never used for pvectors because there is a better alternative:

  pvector<int> copy = count;

The = operator works on pvectors in pretty much the way you would expect.


Last Update: 2005-12-05