Thread: implicit constructor and class access

  1. #1

    implicit constructor and class access

    Hi all,
    I have two questions.

    1. What is meant by an "implicit constructor"?
    2. Can a base class access the members of a derived class? Why?

    These are two questions from my homework assignment that i can't find answers for in my C++ book. Thanks for any help!


  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    1. A constructor provided by the compiler, when you don't explicitly specify one. The constructor will provide an empty constructor that takes no arguments and does nothing and a copy constructor that takes the same type of object as a parameter that does a bitwise copy.

    2. If no cast is made, then a base class can only access it's own methods. If any of these methods is declared virtual then the methods will be overrided by the derived class and those will get called. It is possible to access non-virtual derived class methods through casting, but it's not very safe as the base class will be smaller so there is a chance that you will overwrite memory, crash your program, etc.

    If you can't find these in your book (and as they are fairly basic C++ concepts, I doubt this), then you need a different text.

Popular pages Recent additions subscribe to a feed