[ell-i-developers] Re: Register Assignment Operator (operator = )

  • From: Asif Sardar <engr.asif.sardar@xxxxxxxxxxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Wed, 20 Aug 2014 11:09:01 +0300

Hi,

Very good discussion. I am now memorizing the C++ objected oriented stuff
from my academics :)

In C++ objected oriented programming, the operators and constructors are
defined implicitly by compiler if you do not declare them yourself, which
creates ambiguity in the code.

The *using *or namespace scope identifiers may solve the issue, but if the
operators are declared public in the parent class. Otherwise, it will not
work for private declarations and I may doubt also on protected
declarations in the parent class.

BR,
Asif.




On Wed, Aug 20, 2014 at 8:51 AM, Pekka Nikander <pekka.nikander@xxxxxx>
wrote:

> > I remember we had a brief discussion about why it is necessary to
> > define the assignment operator in every class that inherits Register
> >
> >
> https://github.com/Ell-i/Runtime/blob/master/stm32/emulator/inc/Register.h#L56
> >
> > Why it does not behave as the other inherited operators?
>
> Excellent question!
>
> > I think this is quite related:
> >
> >
> http://www.learncpp.com/cpp-tutorial/911-the-copy-constructor-and-overloading-the-assignment-operator/
> > //----
>
> After some googling, this seems to be the most relevant answer I was able
> to find:
>
>
> http://stackoverflow.com/questions/3882186/trouble-with-inheritance-of-operator-in-c
>
> Hence, it looks like that we actually *can* avoid rewriting the operator
> over and over through the "using" declaration, as discussed in the referred
> page.  (BTW, this was all new to me -- thanks for making me to learn new
> things. :-)
>
> Feel free to explore and provide a pull request!
>
> --Pekka
>
>


-- 



*With Best Regards,Asif Sardar.+358 43 8265795*

Other related posts: