returning a function pointer

hello
i'm having some troble with returning a function pointer;
here's the problem
le's say i have class lyke this one
class A
{
public:
type1 func1(type2,type3); /* this is the function to witch i want to return a pointer; */

type1 (* return_pointerc_fct(void))(type2,type3)

};

type1 (* A::return_pointerc_fct(void))(type2,type3)
{
// tried 2 possibilities
return &func1; //eror

// and
return &A::func1; // eror

}

i would like to assign the pointer a a function outside the class .
Pointer to method have a complex syntax, if I understand what you want to do, this should be the right way:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class A
{
    public:
        typedef type1 (A::*ptr_to_func)(type2,type3); // ptr_to_func = new type: pounter to type1 function(type2,type3)

        type1 func1(type2,type3); // function

        ptr_to_func return_pointerc_fct(); // function returning a pointer

};

A::ptr_to_func A::return_pointerc_fct()
{
        return &A::func1;
}
Last edited on
Topic archived. No new replies allowed.