Thread: inheritance or polymorphism

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    3

    inheritance or polymorphism

    the movement behavior of the mammals - Bat and Whales, exhibits which of the following (inheritance or polymorphism)

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    What do you think, and why? (Frankly, both can be correct depending on the situation, so the why determines if you have the right idea.)
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    3
    i think poly coz the statement refer to the movement.....but most of my friends said inheritance..im very confuse this question is going to come out tomorrow on my exam paper... need ur help what do you think...?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Well, put it in another way: given this problem, would you create a hierarchy of mammals, or a hierarchy of movements? If it is the former, then you would answer polymorphism. If it is the latter, then you would answer inheritance.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    3
    thanks a lot

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. polymorphism and inheritance
    By stewie griffin in forum C++ Programming
    Replies: 12
    Last Post: 01-16-2009, 02:45 AM
  2. Replies: 8
    Last Post: 01-13-2008, 05:57 PM
  3. Polymorphism, inheritance and containers
    By musicalhamster in forum C++ Programming
    Replies: 6
    Last Post: 11-27-2007, 10:23 AM
  4. Inheritance and Polymorphism
    By bench386 in forum C++ Programming
    Replies: 2
    Last Post: 03-18-2004, 10:19 PM
  5. inheritance and polymorphism uses...
    By tetra in forum C++ Programming
    Replies: 5
    Last Post: 05-06-2003, 05:30 PM