I can't figure out why I keep getting a syntax error from these functions
Code:
NODE.H //holds a value. no problems with this class
-------------------------------
#ifndef NODE_H
#define NODE_H
#include <cstdlib>
template <class Item>
class node
{
public:
node(Item the_data = Item(), node* link_field = NULL)
{data = the_data; link = link_field;}
void set_link(node* link_field) {link = link_field;}
void set_data(Item value) {data = value;}
Item get_data() {return data;}
node* get_link() {return link;}
const Item get_data() const {return data;}
const node* get_link() const {return link;}
private:
Item data;
node* link;
};
#endif
BAG.H //linked list class, holds a set
-----------------------------------------------
#ifndef BAG_H
#define BAG_H
#include <cstdlib>
template <class Item>
class bag
{
public:
bag() {head = NULL;}
void print();
void input();
void set_head(node<Item>* n1) {head = n1;}
node<Item>* get_head() {return head;}
const node<Item>* get_head() const {return head;}
bool is_element(Item value);
bag get_union(bag b1);
//here's what my friend functions look like, don't know why
//they don't work
friend bool is_subset <>(const bag& b1, const bag& b2);
friend bag get_difference <>(const bag& b1, const bag& b2);
friend bag get_intersect <>(const bag& b1, const bag& b2);
private:
node<Item>* head;
};
it's divided up into four files. node.h (header containing inline functions of node class), bag.h(header file for bag class), bag.template (implementation for bag class), and main.cc (application file)
and here's what the error message I get looks like:
Code:
bag.h:40: error: 'is_subset' is neither function nor member function; cannot be declared friend
bag.h:40: error: expected ';' before '<' token
the error is the same with get_difference and get_intersect. I can't figure out what I'm doing wrong
I don't think you need to see the definitions for this, but if you do let me know
EDIT: I'm using the g++ compiler on a unix operating system