Web lists-archives.com

[Mingw-users] Copy Constructor; Programming Principles and Practice Using C++

I've been slowly going through Bjarne Stroustrup's Programming Principles and Practice Using C++ 2nd Edition (covering C++11 and C++14). The code I'm having issues with is in 18.3.1 Copy Constructor. The book code is

class Vector{
     int sz;  // size
     double *elem;   // pointer to the element
       Vector(const Vector& arg);

Vector::Vector(const Vector& arg) : sz {arg.sz}, elem{new double[arg.sz]}
      std::copy(arg, arg + sz, elem);

Upon compiling it, I get:
samp18_1.cpp:30:16: error: no match for 'operator+' (operand types are 'const Vector' and 'int')
samp18_1.cpp:30:18: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
samp18_1.cpp:30:18: note:   mismatched types 'const std::move_iterator<_Iterator>' and 'int'

What do I need to change in order to get it to compile? Every Google search I've done states the above code is correct and valid, but not really finding the same error to get a solution for.

Clayton Weaver
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe