Advertisement
Guest User

Method pointers help

a guest
Apr 12th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. class A {
  2. public:
  3.     float method1(float a) { does something with a}
  4. };
  5.  
  6. class B {
  7. public:
  8.     float method2(float a) { does something with a}
  9.     float anothermethod2(float a) { does something with a}
  10. };
  11.  
  12. class B {
  13. public:
  14.     float method3(float a) { does something with a}
  15. };
  16.  
  17. int main()
  18. {
  19.     std::vector< (what do i put in here?)> MethodsToCall;
  20.  
  21.     MethodsToCall.pushback(  A::method1 );
  22.     MethodsToCall.pushback(  B::method2 );
  23.     MethodsToCall.pushback(  C::method3 );
  24.     MethodsToCall.pushback(  B::anothermethod2 );
  25.  
  26.     for(F : MethodsToCall )
  27.     {
  28.         std::cout << F(3.5) << std::endl;
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement