generic c

hi i am a student and i am learning programming
last semester i have learned c and now we learn c++;
well my question is;
lets say i have i generic class linkedlist;
and i need to send pointers to the functions.
the class name is Linkedlist
so i have wrote the argument like that
Linkedlist(Cmp cmp,Cpy cpy,Prnt prnt,Dst dst)(compare copy print and destroy functions)
i have another class that her name is Board;
and i defined the functions in the class and i like to send pointers the linked llist so like that i can create the list

here is the headers of the classes

class Board
{
public:
Board(int x=15,int y=15);
~Board();
int Getx() { return m_x; }
void Setx(int val) { m_x = val; }
int Gety() { return m_y; }
void Sety(int val) { m_y = val; }
Elm cpy(Elm elm);
int cmp(Elm elm1,Elm elm2){return 0;}
void dst(Elm elm){delete ((Board*)elm);return;}


private:
int m_x;
int m_y;

};


list.h/////////////
typedef enum {SUCCES,FAILED,OUT_OF_MEMORY}Result;
typedef void* Elm;
typedef int (*Cmp)(Elm elm1,Elm elm2);
typedef Elm(*Cpy)(Elm elm);
typedef void(*Prnt)(Elm elm);
typedef void(*Dst)(Elm elm);

class Linkedlist
{
public:
Linkedlist(Cmp cmpp=NULL,Cpy cpyy=NULL,Prnt prntt=NULL,Dst dstt=NULL);
~Linkedlist();
void Insert(Elm elm);
Elm Jitem(int counter);

private:
int m_counter;
Cmp m_cmp;
Prnt m_prnt;
Cpy m_cpy;
Dst m_Dst;
struct Node
{
Node* next;
Elm elm;

}*head;
};


the problem is in my main.
i like to make a linked list of board. and i wrote that


int main()
{
int x,y,f=0;

Board a();
Linkedlist Blist(a.cmp(),a.cpy(),NULL,a.dst());

}


what is wrong with that?
Board a();

declares a function named "a" that takes no parameters and returns a Board.

Board a;

declares a variable named "a" of type Board, and calls the default constructor to initialize.
i wchanged it to Board a;
but there is still a problem.
i like to send the adress of the functions cmp cpy dst prnt that are in my Board class to the linkedlist class
what should i write?
Send the address of the functions...? You mean like a function pointer?
yep....
Topic archived. No new replies allowed.