#include <iostream>
#include <string>
#include <vector>
using namespace std;
int sum(initializer_list<int> n)
{
int s = 0;
for (auto beg = n.begin(); beg != n.end(); ++beg)
s += *beg;
return s;
}
int main()
{
int s;
int a = 1, b = 2, c = 3;
int d[3]{ 4,5,6 };
s = sum({ a, b, c, d[0], d[1], d[2] });
cout << s << endl;
system("pause");
return 0;
}
C++ Primer(第五版)练习6.27
最新推荐文章于 2022-07-22 17:57:43 发布