FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

need help debugging C++ script.

 


Requell
Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <string>

template <class W>
friend int& operator [](List<W> &item, int W);

template <class W>
int& operator [](List<W> &item, int W)
{
  struct node <W> * temp = item.root;
  while(temp->next->count != W)
  {
    temp->data;
    temp=temp->next;
  }
   return temp->data;
}



I receive this compile error.

`int& operator[](List<W>&, int)' must be a nonstatic member function

What im suposta do is write a function to overload the [] operator so that it acts like an index of an array on a linked list. What am I doing wrong? it looks fine to me.
Indi
Requell wrote:
`int& operator[](List<W>&, int)' must be a nonstatic member function

Like it says, it must be a non-static member function, not a friend function.
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.