[GCC-XML] virtual function
Nindi Singh
nindi73 at yahoo.co.uk
Sat Feb 2 10:05:41 EST 2008
Brad
Thanks, your absoluteley right BUT I didn't know that. I'll be sure to reference the standard before posting in the future.
N
PS It'd probably make a good interview question !
----- Original Message ----
> From: Brad King <brad.king at kitware.com>
> To: Nindi Singh <nindi73 at yahoo.co.uk>
> Cc: gccxml at gccxml.org
> Sent: Saturday, 2 February, 2008 2:21:35 PM
> Subject: Re: [GCC-XML] virtual function
>
> Nindi
>
Singh
>
wrote:
> >
>
class
>
Base
>
{
> >
>
>
public:
> >
>
>
>
virtual
>
void
>
func()=0;
> >
>
};
> >
> >
>
class
>
Derived:public
>
Base
>
{
> >
>
>
public:
> >
>
>
>
void
>
func(){}
> >
>
};
> [snip]
> >
>
I
>
am
>
curious
>
the
>
method
>
'func'
>
in
>
class
>
Derived
>
is
>
described
>
as
>
virtual.
>
Its
>
not.
>
If
>
I
>
am
>
missing
>
something,
>
then
>
how
>
can
>
I
>
tell
>
whether
>
a
>
function
>
'may'
>
be
>
overloaded
>
in
>
a
>
derived
>
class
>
or
>
not.
>
> Yes,
>
it
>
is
>
declared
>
virtual.
>
It
>
does
>
not
>
matter
>
whether
>
the
>
virtual
> keyword
>
is
>
present.
>
If
>
there
>
is
>
a
>
function
>
with
>
the
>
same
>
signature
>
in
> the
>
parent
>
class
>
that
>
is
>
declared
>
virtual
>
it
>
implicitly
>
makes
>
your
> function
>
virtual.
>
This
>
is
>
a
>
C++
>
rule.
>
> If
>
instead
>
you
>
write
>
> class
>
Base
>
{
>
>
>
public:
>
>
>
>
virtual
>
void
>
func()=0;
> };
> class
>
Derived:
>
public
>
Base
>
{
>
>
>
public:
>
>
>
>
void
>
func(int)
>
{}
> };
>
> then
>
Derived::func
>
is
>
not
>
virtual
>
because
>
it
>
does
>
not
>
match
>
the
> signature
>
from
>
Base::func.
>
Instead
>
you
>
will
>
be
>
left
>
with
>
an
>
abstract
> class
>
because
>
Base::func
>
is
>
pure-virtual
>
so
>
it
>
must
>
be
>
defined
>
in
> Derived
>
to
>
make
>
it
>
a
>
concrete
>
type.
>
> -Brad
>
>
___________________________________________________________
Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/
More information about the gccxml
mailing list