有如下程序: #include <iostream> using namespace std; class Sample { friend long fun(Sample s); public: Sample(long a) {x=a;} private: long x; }; long fun(Sample s) { if(s.x < 2) return 1; return s.x * fun(Sample(s.x-1)); } int main() { int stun = 0; for (int i=0; i<6; i++) {sum += fun(Sample(i));} cout << sum; return 0; }运行时输出的结果是
A.120
B.16
C.154
D.34
[单选题]有如下程序: include using namespace std; class point {int x,y; public:point( i有如下程序: #include <iostream> using namespace std; class point { int x, y; public: point( int vx, int vy ) { x = vx; y = vy; } point ( ) { x = 0; y = 0; } point operator+( point p
[单选题]有如下程序: include using namespace std; class Obj { static in有如下程序: #include <iostream> using namespace std; class Obj { static int i; public: Obj( ){i++;} ~Obj(){i--;} static int getVal( ){ return i;} }; int Obj::i=0; void f() {Obj ob2; cout<<ob2.getVa
[单选题]有如下程序: include using namespace std; class B { public:有如下程序: #include <iostream> using namespace std; class B { public: virtual void show() { cout<<"B"; } }; class D: public B{ public: void show() { cout<<"D"; } }; void fun1(B *ptr) { ptr->show()
[单选题]有如下程序: include using namespace std; class Part{ public:有如下程序: #include <iostream> using namespace std; class Part{ public: Part(int x=0):val(x) { cout<<val; } ~Part() { cout<<val; } private: int val; }; class Whole { public: Whole(int x, int y, int
[单选题]有如下程序: include using namespace std; class MyClass { public:有如下程序: #include <iostream> using namespace std; class MyClass { public: MyClass() { ++count; } ~MyClass() { --count; } static int getCount() { return count; } private: static int count; }; i
[单选题]有如下程序: include using namespace std; class Base { public:有如下程序: #include <iostream> using namespace std; class Base { public: Base(int x=0) { cout<<x; } } class Derived: public Base{ public: Derived(int x=0) { cout<<x; } private: Base val; }; int mai
[单选题]有如下程序:include using namespace std;using namespace std;class Base{public:vo有如下程序: #include <iostream> using namespace std; using namespace std; class Base{ public: void fun( ){cout<<"Base::fun"<<endl:} }; class Derived:public Base{ public: void fun(
[单选题]有如下程序: include using namespace std; int main() { char st有如下程序: #include <iostream> using namespace std; int main() { char str[100], *p; cout<<"Please input a string:"; cin>>str; p=str; for (int i=0; *p!='/0'; p++,i++); cout<<i<<endl; return 0; }
[主观题]有如下程序: include using namespace std; int strle(char a[],char b[]) {int num=有如下程序:include <iostream>using namespace std;int strle(char a[],char b[]){int num=O,n=O;while (* (a+num) !='/0')num++;while (b [n] ){* (a+num)=b [n];num++;n++;}return(num);}i
[试题]有如下程序: include using namespace std; class Monitor{ public: Monitor(cha有如下程序:include<iostream>using namespace std;class Monitor{public:Monitor(char t):type(t){ }void Print( )const{cout<<"The type of monitor is"<<type< private:char type;};class Com