Re: call base class function or derived class function
- From: George <George@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 16 Mar 2008 23:22:00 -0700
Sorry, since I post a wrong section of code in the original question. so I
repost and ask for advice.
Here is the correct code. My question is simple and there is no
contradiction and I am just asking for why for the result as a best
description.
My question is, in main, function call goo through g.goo (called in function
goo in
class Foo) will call foo in class Goo, other than foo in class Foo, because
we are using an instance of Goo g and no matter execution in which class,
right?
[Code]
#include <iostream>
using namespace std;
class Foo {
public:
void goo()
{
foo(); // will call foo in class Goo
}
private:
virtual void foo() = 0;
};
void Foo::foo()
{
cout << "I am here. " << endl;
}
class Goo : public Foo {
public:
void foo()
{
Foo::foo();
}
};
int main()
{
Goo g;
g.goo();
return 0;
}
[/Code]
regards,
George
.
- Follow-Ups:
- Re: call base class function or derived class function
- From: Abhishek Padmanabh
- Re: call base class function or derived class function
- References:
- Re: call base class function or derived class function
- From: Igor Tandetnik
- Re: call base class function or derived class function
- From: George
- Re: call base class function or derived class function
- From: Abhishek Padmanabh
- Re: call base class function or derived class function
- Prev by Date: Re: exporting classes from DLL using def file and NONAME
- Next by Date: Re: why private virtual function?
- Previous by thread: Re: call base class function or derived class function
- Next by thread: Re: call base class function or derived class function
- Index(es):
Relevant Pages
|