利用构造函数求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();

}

    原文作者:keedor
    原文地址: https://www.cnblogs.com/keedor/p/4376514.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞