In this game, post confusing or hard to understand code, and the reader will try to figure out how it works.
I will start with a small C++ program that uses #define's.

 #include <iostream>
 #include <string>

 using namespace std;

 #define FUNCTION(?????) ??????

 FUNCTION(inline, int, hello,
 for(int d = 0; d < i; d++) {
     cout << "\nhello " << t << d << "\n";
 }
 return i;
 );
 int main()  {
     return hello(5, "world ");
 }

The output of the program on Linux is:

    hello world 0
    hello world 1
    hello world 2
    hello world 3
    hello world 4

    Process returned 5 (0x5)

Anyone who guesses what the definition of FUNCTION() is, gets a cookie!

Another sample in C++. It uses template metaprogramming to calculate Fib at compile time. It uses tree recursion so it is not really efficient, but it works :)

#include <cstdio>

template <int i>
struct Fib {
   const static int value = Fib<i-1>::value + Fib<i-2>::value;
};

template <>
struct Fib<0> {
   const static int value = 1;
};
template <>
struct Fib<1> {
   const static int value = 1;
};

int main()  {
    printf("%i", Fib<25>::value);
}

I don't think anyone wants to play

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.