M
Michael
Ok,
I understand the function pointers in C, but i'm a bit more confused in c++.
Firstly, as i understand it, a static member function can be
"function-pointed" to as a normal c function, but in order to pointer to f2,
an object must be instatiated. Is this correct??
class cl
{
public:
static void f1(int a) {}
void f2(int b) {}
};
Furthermore if I have a virtual function over-ridden in a derived class
class cl2
{
public:
virtual void a(int a){cout <<"BASE called"};
};
class Bcl2 : cl2
{
public:
void a(int a){cout <<"DERIVED called"};
};
cl2* ptr = new Bcl2;
now if I were to take a pointer to a of ptr, I assume that the 'vtables'
would correctly sort it out so i get the second "DERIVED called" function.
Is this right?
Lastly, what are functors, I any one knows of anywhere they are explained
simply and slowly I'd be grateful, I seem to keep getting bogged down wih
templates when I read them!!!
Thanks
Mike
I understand the function pointers in C, but i'm a bit more confused in c++.
Firstly, as i understand it, a static member function can be
"function-pointed" to as a normal c function, but in order to pointer to f2,
an object must be instatiated. Is this correct??
class cl
{
public:
static void f1(int a) {}
void f2(int b) {}
};
Furthermore if I have a virtual function over-ridden in a derived class
class cl2
{
public:
virtual void a(int a){cout <<"BASE called"};
};
class Bcl2 : cl2
{
public:
void a(int a){cout <<"DERIVED called"};
};
cl2* ptr = new Bcl2;
now if I were to take a pointer to a of ptr, I assume that the 'vtables'
would correctly sort it out so i get the second "DERIVED called" function.
Is this right?
Lastly, what are functors, I any one knows of anywhere they are explained
simply and slowly I'd be grateful, I seem to keep getting bogged down wih
templates when I read them!!!
Thanks
Mike