access to private function.

Discussion in 'C++' started by ishekar, Jul 23, 2003.

  1. ishekar

    ishekar Guest

    Hi,

    class A
    {
    public:
    virtual void x(){cout<<"inside A"<<endl;};
    }

    class B : public A
    {
    private:
    void x(){cout<<"inside B"<<endl;};
    }

    main
    {
    B b;
    A& a=b;
    a.x(); // this prints "inside B" but b's x() is a private method.
    }

    is this a compiler bug or a standard. i am not able to understand. could
    anyone have a opinion on this.

    Thanks
    ishekar, Jul 23, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qazmlp
    Replies:
    19
    Views:
    777
    Daniel T.
    Feb 4, 2004
  2. DaveLessnau
    Replies:
    3
    Views:
    415
    Howard
    May 16, 2005
  3. Mike
    Replies:
    9
    Views:
    360
  4. Gregor Kofler
    Replies:
    6
    Views:
    205
    Gregor Kofler
    Jun 27, 2008
  5. jacob navia
    Replies:
    1
    Views:
    370
    gwowen
    Apr 3, 2012
Loading...

Share This Page