delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/04/10:13:05

From: eyal DOT ben-david AT aks DOT com
To: blizzar AT hem1 DOT passagen DOT se
cc: djgpp AT delorie DOT com
Message-ID: <422564AC.005299F1.00@aks.com>
Date: Wed, 4 Jun 1997 17:08:32 +0200
Subject: Re: Virtual functions
Mime-Version: 1.0



> If I have the following two classes:
> class parent
> {
> public:
>        virtual int foo(void)
>       {
>                cprintf("Parent foo");
>        }
> };
> class child : public parent
> {
> public:
>        int foo(void)
>        {
>                cprintf("Child foo");
>        }
> };
> Is there some way I can call the parent::foo() from within child::foo()?
Or
> is this just impossible?

It is possible.

class new_born_child
{
public:
        int foo()
        {
              return cprintf("new_born_child foo");
        }

        int ExampleOfParentFoo()
        {
              return parent::foo();
         }
};


by the way,  the code you gave will not compile ("missing return value"
error)

Eyal.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019