Thread: Pointers to inherited classes

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912

    Arrow Pointers to inherited classes

    I have class #1. Class #2, is completely unrelated, class #3 is derived from #1, class 4 is derived from #1, And class 5 had multiple inheritance from both #2 and #1. Class 6 contains a pointer to type class #1 (these are not the real names). Can that pointer also be used to hold the address of classes 3, 4, and 5? If not all, which ones? Thanks if you can help.

    Sean Mackrory
    [email protected]

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You'll be able to use the pointer to call any virtual methods in the derived classes that are inherited from class 1 but if the pointer is to a class 5 instance then it will not be able to call any virtual methods derived from class 2 (unless you use a cast).
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 03:20 AM
  2. Help With Inherited Classes Needed
    By elliott in forum C++ Programming
    Replies: 4
    Last Post: 12-11-2005, 09:05 AM
  3. Pointers, Classes, and Errors o my!
    By Scottc1988 in forum C++ Programming
    Replies: 12
    Last Post: 03-13-2003, 10:14 PM
  4. Pointers to classes
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 06-02-2002, 09:25 PM
  5. question time (classes and pointers)
    By swarm in forum C++ Programming
    Replies: 1
    Last Post: 02-20-2002, 11:33 AM