bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: templates and inheritance


From: Greg Bacon
Subject: Re: templates and inheritance
Date: Fri, 12 Apr 2002 19:07:01 -0000

In article <address@hidden>,
    André Pönitz <address@hidden> wrote:

: Greg Bacon <address@hidden> wrote:
:
: [...]
: >     class C: public B<T> {
: >       public:
: >         C() { cout << "C::C called\n"; }
: >     };
: 
: My interpretation:
: Since you do not provide an operator=() for C, the compiler will generate
: one automatically, consequently hiding the ones from B.

So a method shadows all overloaded methods with the same name modulo
mangling from all classes up the inheritance graph?  Does the
Stroustrup book cover this?

: PS: I have not yet encountered a situation where a _virtual_ operator=
: makes sense. This does, of course, not mean anything....

This is a friend's code.  (Honest! :-)  What he's trying to do is
provide objects (here "objects" is a double entendre, using both the
C and C++ definitions) that do some magic when callbacks modify them.
Roughly, the following examples would be equivalent:

    f = 1.2345;

    // we want to know that f was written
    f = 1.2345;
    make_note_of_modification(&f);

Is there a better way to do it in C++?

: -- 
: Those who desire to give up Freedom in order to gain Security,
: will not have, nor do they deserve, either one. (T. Jefferson)

Isn't that a Ben Franklin quote?

Followups set.

Greg
-- 
When in doubt, use brute force.
    -- mjd, "Good Advice and Maxims for Programmers"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]