Web lists-archives.com

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

On 12/18/2016 10:21 AM, Clayton Weaver wrote:
> 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
>    public:
>         Vector(const Vector& arg);
> };
> Vector::Vector(const Vector& arg) : sz {arg.sz <http://arg.sz>},
> elem{new double[arg.sz <http://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'
> etc.
> 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.

In order to diagnose sensibly, folks here will need the complete 
source code that you tried and the exact command line.

Kein-Hong Man (esq.)
Selangor, Malaysia

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