Must assignment be a member function always?

I

Ioannis Vranos

In TC++PL3 on page 676, it is mentioned at the bottom:

"I introduced a new Vector (rather than using a valarray) because I
needed to define assignment (and assignment must be a member function;
11.2.2). However, valarray is a strong candidate for the representation
of that Vector".

OK, the assignment must be defined in a way that performs the evaluation
of U=M*V+W, so we can't use a valarray directly since it has its
assignment operations already defined.

However (and having checked 11.2.2 where I did not find something
relevant), "must assignment be a member function" always?
 
V

Victor Bazarov

Ioannis said:
In TC++PL3 on page 676, it is mentioned at the bottom:

"I introduced a new Vector (rather than using a valarray) because I
needed to define assignment (and assignment must be a member function;
11.2.2). However, valarray is a strong candidate for the
representation of that Vector".

OK, the assignment must be defined in a way that performs the
evaluation of U=M*V+W, so we can't use a valarray directly since it
has its assignment operations already defined.

However (and having checked 11.2.2 where I did not find something
relevant), "must assignment be a member function" always?

See [over.ass]/1, the first sentence.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,310
Latest member
FaustoMont

Latest Threads

Top