Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    middle of nowhere
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Virtual Functions and Inheritance?

    Ok next question. I know that when I declare a pure virtual function in a class, I have to make sure to provide a def. for it in all the classes I derive from it, or that class is also an abstract class. Ok say I derive a class from that class and define that function. Now I derive another class from the second class, but its similar enough that I can use definition of that function from the second class. Do I still have to define that function in the final class, since the first class is it's indirect base? Or will the definition from the second class work?

    Thanks

  • #2
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Shawn,

    Just to make sure I got this right. You have ClassA that has a pure virtual function, ClassB that derives from ClassA and defines all the pure virtual functions in ClassA and ClassC that derives from ClassB.

    If this is the case, then you can create instances of both ClassB and ClassC as the pure virtual function from ClassA is defined by ClassB's implementation.

  • #3
    New Coder
    Join Date
    Oct 2002
    Location
    middle of nowhere
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yep that's the one!

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •