Hello-
OK... i am trying to create a GUI for SDL. everything is fine, except one thing: if i try to create a pointer to a member function from another class, i have to declare the function like so:
class s
{
public:
s(void(t::*s)(void)){
pfunc = s;
}
protected:
void (t::*pfunc)(void);
};
class t
{
public:
t(){
NewS = new s(save);
}
~t(){delete NewS;}
void save(){};
protected:
s* NewS; //whatever
this works, because class s is expecting a pointer from class t. However, this is not very expandable. I can use templates, but if i want to use a non-member if breaks. For example, if i tried to implement the code above like this:
template <class type>
class s
{
public:
s(void(type::*s)(void)){
pfunc = s;
}
protected:
void (type::*pfunc)(void);
};
class t
{
public:
t(){
NewS = new s<t>(save); //still works
}
~t(){delete NewS;}
void save(){};
protected:
s* NewS; //whatever
};
//floating function
void load(){};
int main()
{
s<load> SuperS; //this doesn''t work.
}
does anybody know of a way to do what it is i am trying to accomplish, or should i use templates and forget about floating functions (i mean, i
am using objects, and technically i shouldn''t have this problem, but i would like to offer the ability, if possible.
thanks for your help...
EOF
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.