C++ 03 change a macro to template -


i want change following macro template in c++ 03. useful change type of macro templated function? method pointers useful here?

what best approach this? better way use macro or template in order achieve this?

namespace bp{  class printclass{ public:     printclass(){}      void printone(int i) const{         std::cout << "1" << << "\n";     }      void printtwo(int i) const{         std::cout << "2" << << "\n";     }  };  class testclass{ private:     int d_one;     int d_two;  public:      testclass() : d_one(1), d_two(2){}      const int getone() const{         return d_one;     }     const int gettwo() const {         return d_two;     }  }; }  #define print_macro(print, num) \ {\     testclass t; \     int r = t.get##num();\     print(r);\ } int main(){     using namespace bp;     printclass p;     print_macro(p.printone, two);     print_macro(p.printtwo, one);     return 0; } 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -