[ create a new paste ] login | about

Link: http://codepad.org/BBUz43WK    [ raw code | output | fork ]

C++, pasted on Aug 13:
#include <iostream>

#define DEF_HOGE(x)                             \
  static void x##_hoge(int a);                  \
  static void x##_hoge(double y);

#define DEF_HOGE_IMPL(x)                                \
  void Hoge::x##_hoge(int a)                            \
  {                                                     \
    std::cerr << "int " << a << std::endl;              \
  }                                                     \
  void Hoge::x##_hoge(double a)                         \
  {                                                     \
    std::cerr << "double " << a << std::endl;           \
  }

struct Hoge
{
  DEF_HOGE(foo)
  DEF_HOGE(bar)
};

DEF_HOGE_IMPL(foo)
DEF_HOGE_IMPL(bar)

int main()
{
  Hoge::foo_hoge(10);
  Hoge::bar_hoge(3.5);
  return 0;
}


Output:
1
2
int 10
double 3.5


Create a new paste based on this one


Comments: