Archived

This topic is now archived and is closed to further replies.

logout

Calling the parent class

Recommended Posts

logout    122
How can i call a method in the parent class witch i have overloaded in the child class ?
class CParent
{
   public:
       virtual void Print() { cout << 1 << endl; }
};

class CChild : public CParent
{
  public:
      virtual void Print()
             { 
                 cout << 2 << endl: 
                 // here i want to call the parent so i get the output : "21"
             }
};

How can this be done ?
    

Share this post


Link to post
Share on other sites
fizban75    130
call
  CParent::Print()   
from within
  CChild::Print()   


However, you won't get "21" because you have endl in both functions.

[edited by - fizban75 on March 5, 2003 12:54:52 PM]

[edited by - fizban75 on March 5, 2003 12:55:21 PM]

Share this post


Link to post
Share on other sites