单项选择题
以下程序执行后的输出结果是
#include <iostream>
using namespace std;
void try(int,int,int,int);
int main ()
int x,y,z,r;
x =1 ;
y = 2;
try(x,y,z,r);
cout<<r<<endl;
return 0;
void try(int x,int y,int z,int r)
z = x+y;
x = x*x;
y = y*y;
r = z+x+y;
A.18
B.9
C.10
D.不确定
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有以下程序: class Date public: Date(int y,int m,int d); year = y; month = m; day = d; Date(int y = 2000) year = y; month = 10; day = 1; Date(Date &d) year = d.year; month = d.month; day = d.day; void print() cout<<year<< . <<month<< . <<day<<endl; private: int year,month,day; ; Date fun(Date d) Date temp; temp = d; resurn temp; int main () Date date1 (2000,1,1),date2 (0,0,0); Date date3 (date1); date2 = fun(date3); return 0; 程序执行时,Date类的拷贝构造函数被调用的次数是
A.2
B.3
C.4
D.5
点击查看答案&解析
单项选择题
若有以下程序: #include <iostream> using namespace std; class Base public: Base () x=0; int x; ; class Derived1 : virtual public Base public: Derived1 () x=10; ; class Derived2 : virtual public Base public: Derived2 () x=20; ; class Derived : public Derived1,protected Derived2 ; int main() Derived obi; cout<<obj.x<<endl; return 0; 该程序运行后的输出结果是
A.20
B.30
C.10
D.0
点击查看答案&解析
相关试题
以下程序段共有错误( )处。 #include...
若有以下程序: #include <iostream>...
有以下程序: #include <iostream> u...
有以下程序; #include <iostream> u...
有如下类声明: class MyBASE int k;...