Friend functions

This is a discussion on Friend functions within the C++ Programming forums, part of the General Programming Boards category; is it possible for a derived class to have friend functions of a base class? Im trying to allow only ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    54

    Friend functions

    is it possible for a derived class to have friend functions of a base class?

    Im trying to allow only 2 functions of the derived class access the base classes privates. the base class was inherited publicly.

    I know I could just make mutators functions in the base class, but I want to try doing this without giving main the ability to alter the values simply by calling the base class.
    Last edited by JeremyCAFE; 02-12-2006 at 06:58 PM.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,659
    you could supply accessor functions within protected scope in the base class that the derived class could use, but as far as limiting access to two functions of the derived class I'm not sure if that would be possible. even if it is possible, the solution would likely be complicated and ugly.



    ITSA
    Socket Library!

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    54
    forgot about even using protected. thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Friend Functions
    By rculley1970 in forum C++ Programming
    Replies: 5
    Last Post: 03-25-2007, 03:25 AM
  2. Static member functions more efficient?
    By drrngrvy in forum C++ Programming
    Replies: 6
    Last Post: 06-16-2006, 07:07 AM
  3. Friend template functions
    By lyx in forum C++ Programming
    Replies: 4
    Last Post: 10-02-2003, 01:11 PM
  4. inline friend functions.
    By sean in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2002, 11:37 AM
  5. Visual C++ and friend functions giving errors
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 11-04-2001, 05:55 PM

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