473,498 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling virtual function results in calling function of base class ...

On Andreas Lagemann <an**************@freenet.de> wrote:

Class Base
{
public:
Base() {}

Base(A* a, B* b);

virtual A* foo(P* p, S& s); // using myA and myB
Make sure you have a virtual destructor, private copy constructor and
private assignment operator.
Executing this results in Base::foo being called instead of Der::foo
Did you make a typo or something. It will call Der::foo if your foo
signature is exact the same in Der.
Are you sure you use pointers when you are passing the Der object as a
Base object? To make sure use private copy constructor and private
assignment operator so you will not lose the Der object info when
copying the object.

(what I would expect) ....
What am I doing wrong ?
Typo?
Is that because cstr of Der does not initialize any mebers of Base ?


Nope
Cheers Tim
Jul 22 '05 #1
0 1082

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
2308
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
14
1878
by: mshetty | last post by:
Hi, I get an error "Warning: b::a_method hides the virtual function a::a_method()." on compiling the following code.. #include <iostream.h> class a {
3
11422
by: scott | last post by:
hi all, hope some one can help me. Ill try and explain what im trying to do as best i can. i have a parent class that has a vertual function, lets call it virtual int A(). That vertual function...
8
1606
by: Andreas Lagemann | last post by:
Hi, after browsing FAQ and archive for a while I decided that the following is a legal question. Consider this: Class Base { public: Base() {}
12
1956
by: Peter Cranz | last post by:
hello, I've got the following problem: I have a construct similar like this: namespace A { class X {
11
3393
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
3
2337
by: Klaas Vantournhout | last post by:
Hi, Recently I obtained a problem with virtual inheritance when implementing it in multiple files. To present the problem I have included at the bottom of this post the code of the 4 files. I...
7
24528
by: sam_cit | last post by:
Hi Everyone, I wanted to know as to what is the exact difference between a virtual function and a pure virtual function? Thanks in advance!!!
3
4682
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.