Pure Virtual Polymorphism HELP

This is a discussion on Pure Virtual Polymorphism HELP within the C++ Programming forums, part of the General Programming Boards category; Since I wanted the logic to work with all of the 'plug-in' classes, they needed to be called as if ...

  1. #16
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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,259
    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%.

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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.

Page 2 of 2 FirstFirst 12
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, 03:43 AM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 10:14 PM
  5. virtual or pure virtual
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-01-2001, 06:19 PM

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