using-directive question
From: David Crocker (dcrocker_at_eschertech.ccoomm)
Date: 03/31/04
- Next message: Steven T. Hatton: "Re: using-directive question"
- Previous message: John Harrison: "Re: Compile Time assertions"
- Next in thread: Steven T. Hatton: "Re: using-directive question"
- Reply: Steven T. Hatton: "Re: using-directive question"
- Reply: Leor Zolman: "Re: using-directive question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Mar 2004 15:37:16 +0100
I have a question about using-directives. Consider the following:
class A {
public:
virtual int f() const { return 0;}
}
class B : public A {
public:
int f(int x) const { return x; } // hides the inherited f()
using A :: f; // un-hides the inherited f()
int g() const { return f(); }
}
class C : public B {
public:
int f() const { return 1; }
}
int foo() {
B* temp = new C;
return temp->g();
}
The declaration of g() in class B relies on the directive "using A :: f;" to
make the declaration of f() inherited from A visible. But will the call to
f() within g() bind statically to A :: f() (as it would if I explicitly said
"return A :: f()" instead if using the using-directive), or dynamically A ::
f() or whatever override it? In other words, should the call "foo()" return
0 or 1? I am looking for dynamic binding to occur, but I don't find the C++
Standard clear on this point.
-- David Crocker Escher Technologies www.eschertech.com
- Next message: Steven T. Hatton: "Re: using-directive question"
- Previous message: John Harrison: "Re: Compile Time assertions"
- Next in thread: Steven T. Hatton: "Re: using-directive question"
- Reply: Steven T. Hatton: "Re: using-directive question"
- Reply: Leor Zolman: "Re: using-directive question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|