rt3 发表于 2021-7-4 15:51:52

可变个数参数的用法谢谢

我想知道 把fun() 的 后面几个参数用上的办法,谢谢
#include <iostream>
using namespace std;

void fun(int a, ...){

   int *temp = &a;
   temp++;

   for (int i = 0; i < a; ++i) {
         cout <<"i=="<<i<<"\t"<<"a=="<<a<< "\ttemp point to "<< *temp <<endl;
         temp++;
   }
}
int main(){
   fun(8, 9, 7, 2, 5);
   return 0;
}

人造人 发表于 2021-7-4 15:51:53

https://fishc.com.cn/forum.php?mod=viewthread&tid=198037
页: [1]
查看完整版本: 可变个数参数的用法谢谢