Inheritance and Overloading

This is a discussion on Inheritance and Overloading within the C++ Programming forums, part of the General Programming Boards category; It's been a while since I've used C++, so I'm a bit rusty with inheritance etc. In Java, you're able ...

  1. #1
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718

    Inheritance and Overloading

    It's been a while since I've used C++, so I'm a bit rusty with inheritance etc. In Java, you're able to use the super variable to access functions from a base class, even if you've overloaded them in the subclass. Is it possible to do this in C++?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Like this?

    Code:
    #include <iostream>
    
    class A
    {
    public:
    void Func(){ std::cout<<"A Func()"<<std::endl;}
    
    };
    
    class B: public A
    {
    public:
    void Func(){ std::cout<<"B Func()"<<std::endl;}
    
    };
    
    int main()
    {
    B bObj;
    bObj.A::Func();
    
    }
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    That's exactly what I was looking for. Thanks a lot.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-10-2007, 03:51 PM
  2. How do I override constructor in inheritance?
    By Loduwijk in forum C++ Programming
    Replies: 13
    Last Post: 03-24-2006, 09:36 AM
  3. [B]Overloading Functions In Inheritance[/B]
    By shiv_tech_quest in forum C++ Programming
    Replies: 2
    Last Post: 12-13-2005, 11:50 AM
  4. Overloading an "External" Class?
    By Zeusbwr in forum C# Programming
    Replies: 2
    Last Post: 10-30-2005, 04:34 PM
  5. Inheritance operator overloading
    By global in forum C++ Programming
    Replies: 9
    Last Post: 12-21-2004, 07:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21