From 377139561200992440
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,3cdb654b702f7476,start
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,3cdb654b702f7476,start
X-Google-Attributes: gidf78e5,public
From: "Gerhard W. Gruber" <sparhawk@gmx.at>
Subject: virtual functions
Date: 2000/08/16
Message-ID: <399A78E4.8345D7B@gmx.at>#1/1
X-Deja-AN: 658911936
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Accept-Language: en
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 966431028 mail2news:18214 mail2news mail2news.demon.co.uk
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
MIME-Version: 1.0
Newsgroups: comp.lang.c++,comp.std.c++

Compiler: VisualC++ 5.0

I have a base class that defines a functions as virtual. In the
constructor I call this function and it initializes certain members. Now
I derived another class and there I defined the virtual function as
well,  to override the original one.

Now I call the constructor from the derived class and it in turn calls
the virtual function, but the problem is that the called function is not
the one that overrides it. Instead it calls the function of the base
class.

Maybe I missunderstand something here, but I thought that when I decalre
a function as virtual always the overriding function is called unless I
specify <class>::<function> explicitly.

Is this a missbehaving of the compiler or is this correct?

How can I achive that a overiding function is called? The base class
shouldn't and doesn't know about classes that overrides it but what good
is a virtual function when it doesn't get called?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




