Thread: Friend Function

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    18

    Friend Function

    hello, i am almost done with this program of mine. It is a linked list program, and I have one error left, and it has to do with my friend function. It is used to output stuff in the linked list, but i do not know how to code it right, so i thought maybe someone can help me here. i have provided a link to my program on the internet, and also here is the error i was getting. Thanx a lot!


    C:\ELinkedList\ELinkedList2\LinkedListFileee.cpp(1 4) : error C2039: 'item' : is not a member of 'List'


    http://sourcepost.sytes.net/source/s...source_id=1756

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    The error message tells you exactly what the error is. If 'item' is not a member of 'List', what is it a member of? ListNode.

    I haven't checked it, but your friend function will probably have to do something like -

    output << l.head->item;

    However, as head is supposed to point to the head, you'll be stuck. Perhaps you need to implement something like an iterator; unless you want you operator << to output the entire list, in which case you'll have to internally iterate through it within the function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM