Community discussion forum

AI 1 - Problem Solving (Artificial intelligence)

This is a comment thread discussing AI 1 - Problem Solving (Artificial intelligence)
  • 9 years ago

    This thread is for discussions of AI 1 - Problem Solving (Artificial intelligence).

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 3 years ago

    i need help with an error im recieving.


    i have a template linked list class


    template <class LT>
    class LList
    {
    private:
     class LNode
       {
       public:
         LNode ();
         LT data;
         LNode * next;
       };


    public:
     LList();
     LList( const LList & other);
     ~LList ();
     LList & operator = (const LList & other);
     bool operator == (const LList & other);
     int Size() const;
     friend ostream & operator << <> (ostream & outs, const LList<LT> & L);
     bool InsertFirst (const LT & value);
     bool InsertLast (const LT & value);
     bool DeleteFirst ();
     bool DeleteLast ();
    private:
     LNode * first;
     int size;
    };


    and the friend function is giving me an error:


    template <class LT>
    ostream & operator << (ostream & outs, const LList<LT> & L)
    {
     if (L.first == NULL)
       return outs;


     outs << L.first -> data;


     for (LList<LT>::LNode * n = L.first -> next; n != NULL; n = n -> next)
      {
        outs << ' ' << n -> data;
      }
     return outs;
    }


    i get an error at the for loop... the error is :


    LLIST.tmp: In function std:<img src="images/smilies/redface.gif" width=15>stream& operator&lt;&lt;(std:<img src="images/smilies/redface.gif" width=15>stream&, const LList&lt;LT&gt;&)': <br> LLIST.tmp:111: error: n' undeclared (first use this function)
    LLIST.tmp:111: error: (Each undeclared identifier is reported only once for each function it appears in.)
    LLIST.tmp:33: error: LList&lt;int&gt;::LNode*LList&lt;int&gt;::first' is private <br> LLIST.tmp:106: error: within this context <br> LLIST.tmp:33: error: LList<int>::LNode*LList<int>::first' is private
    LLIST.tmp:109: error: within this context
    application.cpp:19:   instantiated from here
    LLIST.tmp:33: error: LList&lt;int&gt;::LNode*LList&lt;int&gt;::first' is private <br> LLIST.tmp:111: error: within this context <br> LLIST.tmp:111: error: dependent-name LList<LT>::LNode' is parsed as a non-type, but instantiation yields a type
    LLIST.tmp:111: note: say `typename  LList<LT>::LNode' if a type is meant


    i know these all have to do with friend and being private, what do i do?!?!

Post a reply

Enter your message below

Sign in or Join us (it's free).