FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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.
abhinavm24
@ requell try rewriting the code using the required function using it as non static member for the template rather than the member funcction.
also try relooking at the syntax for the same also please quote the compiler use are using to process the binary. Smile
Related topics
Help with C++
Flash - Photo Gallery - need help please.
Need help with php script
[*RESOLVED*] Please close for me.
Need help making logout script
Need help with PHP script[RESOLVED]
Need help with logger script. (half done)
need help with a script
need help with a script for vb its not to hard i think
Help debugging C++ program
Help! This small script has logical problems. Please help
Help With C++ Searching
Need Help. Post - Mail script failure
Any help with C++?
Reply to topic    Frihost Forum Index -> Scripting -> Others

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