implicit constructor and class access

This is a discussion on implicit constructor and class access within the C++ Programming forums, part of the General Programming Boards category; Hi all, I have two questions. 1. What is meant by an "implicit constructor"? 2. Can a base class access ...

  1. #1
    Clarinetster
    Guest

    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!

    Clarinetster

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    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.
    zen

Popular pages Recent additions subscribe to a feed

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