fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct counter{
  5. #define COUNTER_MEMBER(TYPE,NAME) TYPE NAME;
  6. COUNTER_MEMBER(int, a);
  7. COUNTER_MEMBER(int, b);
  8. };
  9.  
  10.  
  11. int add_members(const counter &obj) {
  12. int sum = 0;
  13. #define COUNTER_MEMBER(TYPE,NAME) sum += obj.NAME;
  14. COUNTER_MEMBER(int, a);
  15. COUNTER_MEMBER(int, b);
  16. return sum; /* I hope there was no overflow */
  17. }
  18.  
  19. int main() {
  20. counter obj;
  21. obj.a = 10;
  22. obj.b = 42;
  23. cout << add_members(obj) << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
52