access to private function.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ishekar

    access to private function.

    Hi,

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

    class B : public A
    {
    private:
    void x(){cout<<"insi de 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



Working...