Jakob Bieling wrote:
> Hi,
>
> Recently, I have seen code where the assignment operator has a return
> type 'void'. I do understand that it is a 'bad idea' in the sense that I
> am limiting myself, when using that operator= (ie. v = w = x would not be
> possible). But I asked myself if this is legal. Even though I would not
> know why this should be illegal (Standard did not give me a clue either),
> I am not 100% sure.
Yes, it is legal. However,AFAIK, you might not be able to use that class as
element type for standard containers since they could depend on the
assignment operator returning something.
> Second question is about (copy) c'tors: Am I right in saying that a
> copy c'tor is provided by the compiler whenever there is now copy
> c'tor (but there may be other c'tors)?
Yes.
> Also, a default c'tor is only provided by the compiler, when there is
> no c'tor at all, correct?
.... when there is no _user-defined_ constructor...
Aside from that, it's correct.
|