derived class

This is a discussion on derived class within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, What does the following statement about derived class mean? http://www.gotw.ca/gotw/059.htm -------------------- Unreasonable Statement #1: "Polymorphism doesn't work in ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    derived class

    Hello everyone,


    What does the following statement about derived class mean?

    http://www.gotw.ca/gotw/059.htm

    --------------------
    Unreasonable Statement #1: "Polymorphism doesn't work in C++ because you can't make an arbitrary class usable in place of a Base& without changing it (to derive from Base)."
    --------------------


    thanks in advance,
    George

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,588
    It means that object oriented polymorphism in C++ needs inheritance, so if you disallow changes to use inheritance, it is unreasonable to state that polymorphism does not work in C++.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks laserlight,


    What means "disallow changes"? For example?

    Quote Originally Posted by laserlight View Post
    It means that object oriented polymorphism in C++ needs inheritance, so if you disallow changes to use inheritance, it is unreasonable to state that polymorphism does not work in C++.

    regards,
    George

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,588
    What means "disallow changes"? For example?
    You are not allowed to edit any of the code related to the class. Yes, close your text editor or IDE right now.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Hi laserlight,


    Why do I need to modify the base class if I want to write a derived class?

    Quote Originally Posted by laserlight View Post
    You are not allowed to edit any of the code related to the class. Yes, close your text editor or IDE right now.

    regards,
    George

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,588
    Why do I need to modify the base class if I want to write a derived class?
    You need to modify the arbitrary class to make it a derived class.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks laserlight,


    Question answered.

    Quote Originally Posted by laserlight View Post
    You need to modify the arbitrary class to make it a derived class.

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. call base class function or derived class function
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 03-18-2008, 05:23 AM
  2. Two conceptual questions
    By AntiScience in forum C++ Programming
    Replies: 3
    Last Post: 11-01-2007, 11:36 AM
  3. derived class can not access base class protected member?
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2007, 06:32 PM
  4. Replies: 4
    Last Post: 12-28-2002, 11:29 PM
  5. Constructors + Derived class
    By MethodMan in forum C++ Programming
    Replies: 6
    Last Post: 11-10-2002, 04:05 PM

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