Thread: Quick Inheritance questions

  1. #1
    Registered User
    Join Date
    Jun 2002

    Quick Inheritance questions


    I am performing inheritance on a class entitled "Layer". My derived classes will be entitled "Point", "Line" and "Polygon".

    My questions are as follows:

    1) Do the base classes require a default constructor (with default attribute assignment)?

    2) I have a destructor in my base class and my derived class. Do I need to call the base class constructor in my derived class? My compiler gave me errors upon trying.

    3) Can you call a derived class (my "Point" class mentioned above) from a base class (my "Layer" class mentioned above).

    Thanks for everyone's help
    Last edited by VanJay011379; 07-22-2002 at 09:14 AM.
    " . . . and I lay awake, big dreamers never sleep." - David Lee Roth

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    1. No, but they do require a constructor. If you aren't calling one explicitly in the initailizer list, the default constructor will be called if it has one, or else you'll get an error.

    2. The base class destructor is called automatically

    3. If Layer takes a Point argument, or has a pointer member, then it can call a Point method. Otherwise, it can't. However, you can do the opposite, namely call a Layer method from Point.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Two quick questions about open file dialog boxes
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 04-05-2005, 08:49 AM
  2. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 10:06 AM
  3. A quick question(s)
    By EvBladeRunnervE in forum C++ Programming
    Replies: 3
    Last Post: 02-17-2003, 09:39 PM
  4. 2 quick questions
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 11-29-2001, 12:32 AM
  5. A few quick questions...
    By cpp4ever in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2001, 09:28 AM