Like Tree4Likes

Member function from class as a friend in another class

This is a discussion on Member function from class as a friend in another class within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by std10093 I have in mind what grumpy said its 1st paragraph. Nowhere did I say that friend ...

  1. #16
    Registered User
    Join Date
    Jun 2005
    Posts
    6,437
    Quote Originally Posted by std10093 View Post
    I have in mind what grumpy said its 1st paragraph.
    Nowhere did I say that friend classes are bad (or not good) things. I said, in effect, that it is best to grant no more access to data within objects than needed. Friend declarations - be they of friend functions, friend classes, or friend member functions - provide a means for selectively grant access.
    Right 98% of the time, and don't care about the other 3%.

  2. #17
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,739
    I suppose that we should design our code, like if it was to be handled by 100 programmers, even though it may be just for fun.
    OK...? But window and screen seem tightly coupled anyway. The only reason screen is different from window is because a window can hold several screens. But assuming we're looking for other options... I'm left wondering why there is no Screen::clear() method that window can call.

  3. #18
    Registered User
    Join Date
    Jun 2005
    Posts
    6,437
    Quote Originally Posted by whiteflags View Post
    The only reason screen is different from window is because a window can hold several screens.
    Technically, a screen can render several windows too. Goes to show, if you are playing with concepts of windows and screens, you need to be clear about what each of them is and each of them isn't.
    Right 98% of the time, and don't care about the other 3%.

  4. #19
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    In my mind the more autonomous/private something is, the better. It's a matter of precaution. But I think we are about to go off topic..
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with namespace function declared as friend of class
    By Programmer_P in forum C++ Programming
    Replies: 7
    Last Post: 09-22-2012, 12:46 PM
  2. Replies: 4
    Last Post: 03-22-2012, 01:11 PM
  3. friend function template class declaration error
    By -EquinoX- in forum C++ Programming
    Replies: 2
    Last Post: 11-20-2009, 12:00 PM
  4. Replies: 8
    Last Post: 03-19-2008, 03:04 AM
  5. Replies: 5
    Last Post: 06-04-2002, 02:33 PM

Tags for this Thread


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