有如下程序#includeusingnamespacestd;classTest{public:Test(){}Test(constTest&t){cout<<1;}};Testfun(Test&u){Testt=u;returnt;}intmain(){Testx,y;x=fun(y);return0;}运行这个程序的输出结果是()
举一反三
- 有如下程序:#includeusing namespace std;Class Testpublic:Test()Test(const Test&t)cout<<1;);Test fun(Test &u)Test t=u;retum t;int main()Test X,y;x=fun(y);retum 0;运行这个程序的输出结果是()。 A: 无输出 B: 1 C: 11 D: 111
- 阅读以下程序,写出运行结果。 #include using namespace std; class Test { private: int num; public: Test(); Test(int n); }; Test::Test() { cout << "Init defa" << endl; num = 0; } Test::Test(int n) { cout << "Init" << " " << n << endl; num = n; } int main() { Test x[2]; Test y(15); return 0; }
- 下列程序的输出结果是_____。#includeusingnamespacestd;templateTfun(Ta,Tb){return(a<=b)?a:b;}intmain(){cout<<fun(3,6)<<','<<fun(3.14F,6.28F)<<endl;return0;}
- 下列程序的输出结果是 _____ 。 #include using namespace std; class Test { public: Test() { cnt++; } ~Test() {cnt--; } static int Count() { returncnt;} private: static int cnt; }; int Test::cnt = 0; int main() { cout << Test::Count()<<' '; Test tl, t2; Test* pT3 = new Test; Test* pT4 = new Test; cout << Test::Count()<<' '; delete pT4; delete pT3; cout << Test::Count()<< endl; return 0; }
- (6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }