Re: how to call parent's operator = function?
From: Michael Leung (Leung__at_163.com)
Date: 05/21/04
- Next message: Miki Peric: "Re: dumpbin (VC7.1)"
- Previous message: Vikas Mishra: "RE: Problem running MFC application comipled with vc++ 7.1 ver"
- In reply to: May Young: "how to call parent's operator = function?"
- Next in thread: Doug Harrison [MVP]: "Re: how to call parent's operator = function?"
- Reply: Doug Harrison [MVP]: "Re: how to call parent's operator = function?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 20 May 2004 18:29:18 -0700
The answer to your question can be found in <<Effective C++>>. Mayers has
explained this very clearly in the book.
USE:
A::operator=(a);
but some old compilers will not accept such syntax. So you can do like
below:
static_cast<A&>(*this) = a;
"May Young" <tony@srac.com> wrote in message
news:40A54E60.4030400@srac.com...
> Hi,
>
> If a parent class and a child class both have an operator = function,
> how does the child's = function call its parent's = function? Thanks
> for your help. Tony
>
>
> class A
> {
> public:
> ...
> A& operator= (const A& a);
> };
>
> class AA : public A
> {
> public:
> AA& operator= (const AA& a);
>
> };
>
> A& A::operator= (const A& a)
> {
> ...
> return *this;
> }
>
> AA& AA::operator= (const AA& a)
> {
> *this A::operator= a; // ?????
> return *this;
> }
>
- Next message: Miki Peric: "Re: dumpbin (VC7.1)"
- Previous message: Vikas Mishra: "RE: Problem running MFC application comipled with vc++ 7.1 ver"
- In reply to: May Young: "how to call parent's operator = function?"
- Next in thread: Doug Harrison [MVP]: "Re: how to call parent's operator = function?"
- Reply: Doug Harrison [MVP]: "Re: how to call parent's operator = function?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|