Thread: Pure Virtual Polymorphism HELP

  1. #16
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Since I wanted the logic to work with all of the 'plug-in' classes, they needed to be called as if it was the abstract class
    Eh?

    I still don't understand why you need the GetClass().

  2. #17
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Bubba View Post
    Eh?

    I still don't understand why you need the GetClass().
    You're right - s/he wouldn't. All objects of a derived class can be treated by default as if they are instances of a base class (not withstanding a couple of techniques that can be used to prevent that, but they're not relevant here).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Syndacate View Post
    Really? I'm not sure they'd have code like that in a 'basic c++ programming' book, and yeah, I've really never seen code like that...but I don't really think I need to 'go back to basics' to find it. It's some weird crap that people in the industry experience that I've been exposed to don't do, so I've never had to worry about it, if I did, I'd probably ask somebody there, or here, or somewhere.

    It looks like it just means that the sub class inherits from that 'instance' - but assuming it doesn't, not sure what it means or how it differs from 'normal' inheritance. Besides, it looks like it becomes a pain with long inheritance chains (ie. GUI frameworks), especially with multiple inheritance.
    There is nothing weird with that code, and yes it is basics.
    That example was really moot since it calls the default constructor on x, but that is done implicitly anyway. But if classA had a non-default constructor that took one or more parameters, then you would have to initialize the object by calling its constructor via the initializer list.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-28-2009, 09:25 AM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Information Regarding Pure Virtual Functions
    By shiv_tech_quest in forum C++ Programming
    Replies: 6
    Last Post: 01-29-2003, 04:43 AM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 11:14 PM
  5. virtual or pure virtual
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-01-2001, 07:19 PM