I
Immortal Nephi
Class A and Class B are different objects. How can pass by Value
choose either A object or B object in the global function. The
function pointer should be able to choose either A's function or B's
function to run.
class A
{
public:
A() {}
~A() {}
void read_write();
};
class B
{
public:
B() {}
~B() {}
void read_write();
};
void run( void (*pF)() )
{
pF();
}
int main()
{
A a;
B b;
run( a.read_write() );
run( b.read_write() );
return 0;
} // end function main
choose either A object or B object in the global function. The
function pointer should be able to choose either A's function or B's
function to run.
class A
{
public:
A() {}
~A() {}
void read_write();
};
class B
{
public:
B() {}
~B() {}
void read_write();
};
void run( void (*pF)() )
{
pF();
}
int main()
{
A a;
B b;
run( a.read_write() );
run( b.read_write() );
return 0;
} // end function main