|
-
September 30th, 2010, 08:47 AM
#3
Re: Calling functions in Pure virtual class
Hi, Lindley,
Thanks for your quick reply.
foo(a, b) is also a pure virtual function, which will be defined later in another class, say, E. If I explicilty tell D to call B::foo, will it invoke E:foo(a, b) in the end, or complain that B:foo(a,b) is pure virtual?
As I understand, what "using B::foo" really does is to embed B:foo in the scope of D. If so, will it be equivalent to repeating declaring foo(int a,int b) in D even if it is pure virtual?
Thanks,
CR
 Originally Posted by Lindley
The compiler stops searching the base class for a method called foo() when it sees one in the derived class, unless you explicitly tell it to do so:
Code:
class D : public B
{
public:
using B::foo;
virtual double foo(int a)
{
doube c = foo(a, 1.0);
return c;
}
}
Note, in this limited example this still won't compile, since it will say that D is an abstract class since nothing in the hierarchy provides a concrete implementation of foo(int,int) which is pure virtual.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|