Subject: [sv-ec] Re: super and virtual func.
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Tue Feb 11 2003 - 13:18:43 PST
C++ does not have the restriction that routines used with
'::' should be virtual -
#include <stdio.h>
class foo {
public:
virtual void whoami() {printf("foo\n");};
virtual void whoami2() {printf("foo\n");};
};
class bar : public foo {
public:
virtual void whoami() {printf("bar\n");};
virtual void whoami2() {foo::whoami();};
};
void sub(foo *fp)
{
fp->whoami();
fp->whoami2();
}
main()
{
bar bq;
bq.whoami();
bq.foo::whoami();
bq.whoami2();
sub(&bq);
}
- gives -
bar
foo
foo
bar
foo
A call with :: is not a virtual call, it's handled the same
as a non-virtual call.
I.e. the restriction in SV doesn't have a precedent in C++.
Kev.
This archive was generated by hypermail 2b28 : Tue Feb 11 2003 - 13:20:14 PST