Thread: Help with inheritance

  1. #1
    Unregistered
    Guest

    Question Help with inheritance

    I have a question. I am studying for an exam and am not clear on something. I have the following class definition.

    class A
    {
    private:
    int x;
    protected:
    int y;
    public:
    int z;
    void f(int k);
    };
    class B : public A
    {
    private:
    int w;
    int f();
    };
    class C : private A
    {
    public:
    int w;
    void f(int K);
    };
    clas D : public B
    {
    public:
    void f();
    };

    //These definitions are in the main()

    A a;

    B b;

    C c;

    //Which of the following are illegal?

    cout<<b.f()<<"/n";

    c.f(3);

    b.z=5;

    c.z=7;

    I looked at all the statements and find that they are all legal?
    Am I right?

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    66
    That is painful to read, use code tags as stated in the sticky thread...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 03:03 PM
  2. Virtual inheritance
    By 6tr6tr in forum C++ Programming
    Replies: 13
    Last Post: 05-07-2008, 11:20 AM
  3. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  4. inheritance and performance
    By kuhnmi in forum C++ Programming
    Replies: 5
    Last Post: 08-04-2004, 12:46 PM
  5. Inheritance vs Composition
    By Panopticon in forum C++ Programming
    Replies: 11
    Last Post: 01-20-2003, 04:41 AM