设有类模板,请实例化 #include[iostream] using namespace std; template[typename numtype] class Classtemple{ public: void setdata( 1 ) { a=x;b=y; } private: numtype a,b; }; int main(){ 2 intobj; intobj.setdata(23,24); ...... }
举一反三
- 下面程序输出的结果是( )。 #include<iostream> using namespace std; class A int X; public: A(int x):x(++x) ~A()cout<<x; ; class B:public A int y; public: B(int y):A(y),y(y) ~B()cout<<y;; ; void main() B b(3); A: 34 B: 43 C: 33 D: 44
- 在下列选项中,没有构成死循环的程序段是______。 A: B: include <;iostream>;using namespace std;void main( ){ int i=2020; while(1) { i=i%100+1;if(i>;100)break; }} C: D: include <;iostream>;using namespace std;void main( ){ for(;;);} E: F: include <;iostream>;using namespace std;void main( ){ int i=36; while(i); --i;} G: H: include <;iostream>;using namespace std;void main( ){int i =10000;do{ ++i;}while(i>;=1000);}
- 下列程序执行后的输出结果是______。 #include [iostream] using namespace std; class A { public: A( ) { cout << "A"; } }; class B { public: B( ) { cout << "B"; } }; class C : public A { private: B b; public: C( ) { cout << "C"; } }; void main ( ) { C obj; } A: CBA B: BAC C: ACB D: ABC
- 设有如下定义:#include [iostream]using namespace std;void main( ){ int arr[]={6,7,8,9,10}; int *ptr; ptr=arr; *(ptr+2)+=2; cout<<*ptr<<','<<*(ptr+2);}则程序段的输出结果为__________。 A: 8,10 B: 6,8 C: 7,9 D: 6,10
- 阅读下列程序,写出运行结果。 #include [iostream] using namespace std; int main() { int a = 1, b = 2; bool x, y; cout [< (a++)+(++b) << endl; cout << a % b << endl; x = !a]b; y = a-- && b; cout << x << endl; cout << y << endl; }