利用构造函数求1到n的和 46

class ConSum{

private:

static int n;

static int sum;

public

ConSum(){++n;sum+n}

static int getSum(){return sum;}

};

   

int ConSum::n=0;

int ConSum::sum=0;

int sum_solution(int n){

ConSum *a=new ConSum[n];

return ConSum::getSum();

}

posted @ 2015-03-29 22:04  keedor  阅读(258)  评论(0编辑  收藏  举报