Marco wrote:
> Hi,
>
> I would like implement a class with a method Draw(),
> .I would like that method Draw() change with another method when the
> state of class change.
> I think to use function pointer to do it, but I don't know how use this
> in a class?
> Can someone do a example?
>
Marco,
Why not create a base class with the Draw() method being declared as
virtual and use a pointer to the base class. The actual Draw() function
can then be defined in descendant classes, (see below).
class Shape
{
public:
virtual void Draw(void);
.
.
.
};
class Square : public Shape
{
public:
void Draw(void);
.
.
.
}
class Circle : public Shape
{
public:
void Draw(void);
.
.
.
}
As for a pointer to a member function see below.
{
void (Shape::*pFnc)(void) = &Shape:

raw
Shape Sample;
(Sample.*pFn)(); // Will call Shape:

raw() function
}
JFJB