Question: I've problem to merge 3 variable become in to one variable:

example :

```
int var1,var2,var3;
int result;
var1 = 1;
var2 = 2;
var3 = 3;

result = ........??;

printf("Result %d",result);

output :
123

```

How can I do this?

Answer: 
Yay, C++11 variadic templates are awesome! Here's a `N`-finitely expandable version, assuming `sum(args) < INT_MAX`

```
template<int max, int ...arguments>
int merge_integers()
{
    int args[] = { arguments... };
    int size = sizeof(args) / sizeof(int);
    int mul = 1;
    int result = 0;

    for (int i = size; i--; )
    {
        result += args[i] * mul;
        mul *= max;
    }

    return result;
}

```

Example usage:

```
printf("%d\n", merge_integers<10, 5, 4, 3, 2, 1>());
printf("%x\n", merge_integers<16, 0xA, 0xB, 0x1, 0x3, 0x5>());
printf("%o\n", merge_integers<8, 1, 2, 3, 4, 7>());

```

Output:

```

54321
ab135
12347

```
Do you really need int variables ? Does string meet you requirements ?

```
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int
main()
{
    int var1 = 1;
    int var2 = 2;
    int var3 = 3;

    ostringstream oss;
    string result;

    oss<<var1<<var2<<var3;

    result = oss.str();
    cout<<result<<endl;
    return 0;
}

```