Today, I try to solve one weird (kind of) question with my friend, .

> 
> Try to get the sum of `1 + 2 + ··· + n`, without using multiplication and division, for, while, if, else, switch, case, ternary expression and other keywords.
> 
> 
> 

Here are our solutions

* **constructor**

```
class Sum
{
public:
    Sum() { ++num; sum += num; }
    static void Init() { num = 0; sum = 0; }
    static unsigned int SumValue() { return sum; }
private:
    static unsigned int num;
    static unsigned int sum;
};
unsigned int Sum::num = 0;
unsigned int Sum::sum = 0;

unsigned int get_sum(unsigned int n)
{
    Sum::Init();

    Sum * tmp = new Sum[n];
    delete[] tmp;

    return Sum::SumValue();
}

```
* **recursive**

```
class Ba
{
public:
    virtual unsigned int sum(unsigned int n)
    {
         return 0;
    }
};

Ba* sumArray[2];

class D : public Ba
{
public:
     virtual unsigned int sum(unsigned int n)
     {
          return sumArray[!!n]->sum(n - 1) + n;
     }
};

unsigned int get_sum2(unsigned int n)
{
    Ba b;
    D d;
    sumArray[0] = &b;
    sumArray[1] = &d;

    return sumArray[1]->sum(n);
}

```

We think maybe this question could be solved var `template`? However, we failed to figure it out. Is it possible to do that with `template`?

BTW, we try to find the same question in this site, but we failed. Sorry to this duplicated question if it is.