| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"puzzlecracker" |
| Date: |
01 Aug 2007 10:09:13 AM |
| Object: |
can operators be inherited? |
I don't recall whether operators, which are members of the class, are
intherited in subclasses?
thanks
.
|
|
| User: "Victor Bazarov" |
|
| Title: Re: can operators be inherited? |
01 Aug 2007 10:22:53 AM |
|
|
puzzlecracker wrote:
I don't recall whether operators, which are members of the class, are
intherited in subclasses?
If you meant to ask whether they were inherited, then, yes, they are,
just like any other function.
If you meant to ask if we thought you didn't recall, we don't know.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
|
|
|
| User: "Victor Bazarov" |
|
| Title: Re: can operators be inherited? |
01 Aug 2007 10:25:37 AM |
|
|
Victor Bazarov wrote:
puzzlecracker wrote:
I don't recall whether operators, which are members of the class, are
intherited in subclasses?
If you meant to ask whether they were inherited, then, yes, they are,
just like any other function.
Correction: except for 'address of', I believe. And keep in mind that
each class has its own operator= that hides any inherited operator=.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
|
|
|
| User: "puzzlecracker" |
|
| Title: Re: can operators be inherited? |
01 Aug 2007 11:07:20 AM |
|
|
On Aug 1, 11:25 am, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
Victor Bazarov wrote:
puzzlecracker wrote:
I don't recall whether operators, which are members of the class, are
intherited in subclasses?
If you meant to ask whether they were inherited, then, yes, they are,
just like any other function.
Correction: except for 'address of', I believe. And keep in mind that
each class has its own operator= that hides any inherited operator=.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Thanks V,
What if I make operators virtual in the base class, would they still
be hidden - or according to the standard, operators cannot be
virtual?
Thanks agai,
.
|
|
|
| User: "James Kanze" |
|
| Title: Re: can operators be inherited? |
02 Aug 2007 03:17:38 AM |
|
|
On Aug 1, 6:07 pm, puzzlecracker <ironsel2...@gmail.com> wrote:
On Aug 1, 11:25 am, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
Victor Bazarov wrote:
puzzlecracker wrote:
I don't recall whether operators, which are members of the class, are
intherited in subclasses?
If you meant to ask whether they were inherited, then, yes, they are,
just like any other function.
Correction: except for 'address of', I believe. And keep in mind that
each class has its own operator=3D that hides any inherited operator=3D.
What if I make operators virtual in the base class, would they still
be hidden - or according to the standard, operators cannot be
virtual?
As far as the definition goes, a user defined operator is just a
function with a funny name, and it obeys all of the rules of a
function.
A more general comment, however: C++ operators are value
oriented, and values and polymorphism don't really mix very
well. So the presence of a virtual operator is *usually* a
symptom of a design error (although there are one or two
specific idioms, like letter/envelope where it makes sense).
Just because you can do something doesn't mean that you should.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34
.
|
|
|
|
| User: "Victor Bazarov" |
|
| Title: Re: can operators be inherited? |
01 Aug 2007 12:18:06 PM |
|
|
puzzlecracker wrote:
[..]
What if I make operators virtual in the base class, would they still
be hidden - or according to the standard, operators cannot be
virtual?
Hiding and overriding are two different concepts, but hiding can be
overcome by "using" declarations (see FAQ).
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
|
|
|
|
|
|
|

|
Related Articles |
|
|