putting it in the friend zone

This is a discussion on putting it in the friend zone within the C++ Programming forums, part of the General Programming Boards category; Hi again. I want a operation in one of my classes (Snake) to be able to use the attributes of ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    27

    putting it in the friend zone

    Hi again.

    I want a operation in one of my classes (Snake) to be able to use the attributes of another class (food), so I want to declare that operation as a friend of food.

    I'm still new and have never used friend before.

    is this the right declaration for the operation?

    Code:
     friend void food::check_collision( );
    if not, where have I went wrong?

    also, when I come to implement and call on check_collision, will i always have to put 'food' in front of it? making is Snake::food::check_collision, or will it still be Snake::check_collision ?

    Update:: Ok, I'm fine on the declaration now, but would still like confirmation when it comes calling the operation


    thanks for the help

    ES
    Last edited by elsparko; 05-18-2010 at 12:49 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Friend cannot inherit from private subclass
    By MWAAAHAAA in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2006, 04:44 PM
  2. arithmetic operator friend functions
    By linucksrox in forum C++ Programming
    Replies: 7
    Last Post: 02-06-2006, 11:39 PM
  3. Problem with friend functions in templated linked list
    By Strait in forum C++ Programming
    Replies: 2
    Last Post: 03-13-2005, 04:24 PM
  4. friend function and friend classes...usage question??
    By actionbasti in forum C++ Programming
    Replies: 2
    Last Post: 10-30-2003, 10:53 PM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM

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