2012.1.3 参数个数可变的函数
#include <afx.h>
#include <iostream>
#include <string>
#include <vector>
#include <io.h>
#include <stdio.h>
#include <fcntl.h>
#include <boost/filesystem.hpp>
#include <iostream>
#include <boost/thread/thread.hpp>
#include <string>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <fstream>
#include <exception>
using namespace std;
using namespace boost;
using namespace boost::filesystem;
using namespace boost::algorithm;
int sum(int num,...)
{
va_list arp;
int s = 0,temp;
va_start(arp,num);
for (int i = 0; i < num; i++)
{
temp = va_arg(arp,int);
s = s + temp;
}
va_end(arp);
return s;
}
int main()
{
// cout<<"this\'s an \"apple\"!"<<'\n';
// cout<<'\102'<<'\a'<<'\n';
cout<<sum(0)<<endl;
cout<<sum(2,1,3)<<endl;
cout<<sum(4,1,2,3,4)<<endl;
}