若下面程序运行时输出结果为 1,A,10.1 2,B,3.5 #include <iostream> using namespace std; int main() { void test(int, cha

admin2009-03-15  11

问题 若下面程序运行时输出结果为
    1,A,10.1
   2,B,3.5
   #include <iostream>
   using namespace std;
   int main()
   {
      void test(int, char, doubie【  】);
      test(1, ’A’, 10.1 );
      test(2, ’B’);
      return 0;
   }
   void test(int a, char b, double c)
   {
      cout<<a<<’,’<<b<<’,’<<c<<endl;
   }

选项

答案3.5

解析 本题考查了函数默认参数的应用。本题定义的函数test()仅仅是按顺序输出了三个形参值,题目中第1次调用该函数会输出1,A,10.1,但第2次调用少了一个实参却要求输出2,B,3.5。由此可见,应该将test()函数的第3个参数声明为默认参数,且默认值为3.5。故应该填入=3.5,或加上形参名c=3.5。
转载请注明原文地址:https://kaotiyun.com/show/rsjp777K
0

相关试题推荐
最新回复(0)