Classes, nonstatic member function?

I'm getting an error about having nonstatic numbers called in a static class function. The problem is, this function isn't static!
The bukkittype.cpp file where I get the errors:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef BUKKITDATATYPE
#define BUKKITDATATYPE
#include "loltype.cpp"
class bukkit_t {
	public:
		int selected;
		lol_t data[];
		lol_t helddata;
		
		bukkit_t(){selected=0;}
		friend bool operator[](const bukkit_t &t,const int& p)
		{
			t.data[selected] | t.helddata;
			t.selected = p;
            return t.helddata | t.data[selected];
		}
};
#define BUKKIT ;bukkit_t

#endif 


The included loltype.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef LOLDATATYPE
#define LOLDATATYPE

#define WIN true
#define FAIL false

typedef enum {
	noob,
	numbar,
	troof,
    lettr
} lol_e;

class lol_t {
	public:
		void *data;
		lol_e type;
	//~ public:
		lol_t() {data = 0; type = numbar;}
		lol_t(NUMBAR n) {data = (void*)new int(n); type = numbar;}
		
		friend std::ostream& operator<<(std::ostream& output, const lol_t& p) {
			if(p.type == numbar)
                output << *((int*)(p.data)) << std::endl;
            else if(p.type == troof)
                output << *((bool*)(p.data)) << std::endl;
            else if(p.type == lettr)
                output << *((char*)(p.data)) << std::endl;
			return output;  // for multiple << operators.
		}
		friend std::istream& operator>>(std::istream& input, lol_t& p) {
			//p.type = lettr;
            input >> *((char*)(p.data));
			return input;  // for multiple << operators.
		}
		friend bool operator> (const lol_t &t, const NUMBAR &i)
		{
			return *((int*)(t.data)) > i;
		}
		friend bool operator< (const lol_t &t, const NUMBAR &i)
		{
			return *((int*)(t.data)) < i;
		}
		friend bool operator<<(lol_t &t, const NUMBAR &i)
		{
            return *((int*)(t.data)) += i;
        }
        friend bool operator>>(lol_t &t, const NUMBAR &i)
		{
            return *((int*)(t.data)) *= i;
        }
        friend bool operator|=(lol_t &t, const NUMBAR &i)
		{
            return *((int*)(t.data)) /= i;
        }
        ////////////////////////////////////////////////////////////////////////
        friend bool operator|(lol_t &t, const int &i)
        {
            t.type = numbar;
            return *((int*)(t.data)) = i;
        }
		friend bool operator|(lol_t &t, const lol_t &i)
        {
            t.type = i.type;
            return *((int*)(t.data)) = *((int*)(i.data));
        }
        friend bool operator|(lol_t &t, const char &i)
        {
            t.type = lettr;
            return *((char*)(t.data)) = i;
        }
        friend bool operator|(lol_t &t, const bool &i)
        {
            t.type = troof;
            return *((bool*)(t.data)) = i;
        }
};

#endif 


BTW, I know that I have a NOOP in the bukkit function. I overloaded it, so that shouldn't be the problem.
The overload function for the [] operator cannot be a friend. It must be a (non-static) member of the class.

Note: As a class member function it would only need one parameter(the subscript)
Great, thank you! This has really helped me out.
So basically I can go like this:
1
2
3
bukkit_t lolrus;
lolrus[5];
lolrus=......

after I finish overloading the other functions to work with the helddata variable?
Topic archived. No new replies allowed.