access a private member function witout using a friend, virtual

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajasekaranrajasekaran
    New Member
    • Jan 2007
    • 1

    access a private member function witout using a friend, virtual

    hi,,,
    i am having a scenario plz help me to find a soln,, its really challenging for me hope it is useful 4 u 2....

    I need to access a private member function witout using a friend, virtual and not modifying the class,, for example consided this

    class X
    {
    private:
    void show() // this is the fn i need to access
    public:
    ,,.........
    ........

    };

    you should not include anything inside the class X and u should access the funciton show()



    Note: Plz dont say anything like # define private public
  • Manjiri
    New Member
    • Nov 2006
    • 40

    #2
    Originally posted by rajasekaranraja sekaran
    hi,,,
    i am having a scenario plz help me to find a soln,, its really challenging for me hope it is useful 4 u 2....

    I need to access a private member function witout using a friend, virtual and not modifying the class,, for example consided this

    class X
    {
    private:
    void show() // this is the fn i need to access
    public:
    ,,.........
    ........

    };

    you should not include anything inside the class X and u should access the funciton show()



    Note: Plz dont say anything like # define private public

    what those dots represents in public section....?
    If you can include some functions in there then u can call from public member function na....

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      The only way you can access a private function is within the class itself - you will have to include a public function whose sole purpose is calling the private function.

      Comment

      Working...