单选题类模板的使用实际上是将类模板实例化成一个具体的{{U}} {{/U}}。
A.类
B.对象
C.函数
D.模板类
单选题为使程序的输出结果为: Base:: fun 那么应在下列程序画线处填入的正确语句是( )。 #include <iostream> using namespace std; class Base { public: void fun () { cout<<"Base: :fun"<<end1; } }; class Derived : public Base { public: void fun ( ) { cout<<"Derived: :fun"<<end1; } }; int main ( ) { Base a,*pb; Derived b; _________; pb->fun(); //调用基类的成员函数 fun() return 0 ; }
单选题下列程序的运行结果为______。
# include<iostream.h>
template<class TT>
class FF
{ TT a1,a2,a3;
public:
FF(TT b1,TT b2,TT b3){a1=b1;a2=b2;a3=b3;}
TT Sum(){return a1+a2+a3;));
void main()
{ FF<int>x(int(1.1),2.3),y(int(4.2),5,6);
cout<<x.Sum()<<""<<y.Sum()<<encIl;}
单选题有以下程序:
#include<iostream. h>
void fun(int a, int b, int c)
{a=456, b=567, c=678;}
void main()
{
int x=10, y=20, z=30;
fun(x, y, z);
cout<<x<<","<<y<<","<<z<<endl;
}
输出结果是______。
单选题有如下程序:
#include
using namespace std;
int main(){
int sum = 0;
for(int i = 0; i <= 3; i += 1){
sum += i;
while(sum<100) sum += i;
}
cout << sum <
单选题有如下程序: #include <iostream.h> using namespace std; class Stack { public: Stack (unsigned n=10):size (n) {rep_=new int [size]; top=0;} Stack (stack for (int i=0;i<size;i++ rip_[i]-s.rep_[i]; top=s.top; } ~Stack() {delete[]rep_;} void poush(int a) {rep_[topj=a; top++;} int pep() { --top; return rep_[top];} bool isEmpty() cons5 [return Top ==0;} private: int*rep_; unsigned size, top; }; int main() { Stack s1; for(int i=1;i<5;i++) s1.push(i); Stack s2(s1); for(i=1;i<3;i++} cout<<s2.pop()<<','; s2.push(6); s1.push(7); while(!s2.isEmpty()) cout<<s2.pop()<<','; return 0; } 执行上面程序的输出是
单选题下列字符串可以用作C++标识符的是______。
单选题有如下程序: #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(); void fun2(B void fun3(B b)b.show(); int main() B b,*p=new D; D d; fun1(p); fun2(b); fun3(d); return 0; 程序的输出结果是( )。 A.BBB B.BBD C.DBB D.DBD
单选题下列不构成无限循环的语句或语句组是______。
单选题有如下程序:
#include<iostream>
using namespace std;
class Pair{
int m;
int n;
public:
Pair(int i,int j): m(i),n(j){}
bool operator>(Pair p)const; //须在类体外给出定义
};
int main( ){
Pair p1(3,4),p2(4,3),p3(4,5);
cout<<(p1>p2)<<(p2>p1)<<(p2>p3)<<(p3>p2);
return 0;
} 运算符函数operator>的功能是比较两个Pair对象的大小,当左边对象大时,返回true,否则返回false。比较规则是首先比较两对象的m成员,m大者为大;当m相等时比较n,n大者为大。程序输出0101,下列对运算符重载函数的正确定义是
单选题一个类的友元函数或友元类能够通过成员操作符访问该类的( )。
单选题软件测试的目的是______。
单选题有下列程序:
# include <stdio.h>
void fun(int*s,int n1,int n2)
{
int i,j,t;
i=n1;j=n2
while(i<j){t=s[i];s[i]=s[j];s[j]=t;i++;j--;}
}
void main()
{
int a[10]={1,2,3,4,5,6,7,8,9,0},k;
fun(a,0,3);fun(a,4,9);fun(a,0,9);
for(k=0;k<10;k++)printf("%d", a[k]);printf
("/n");
}
程序的运行结果是______ 。
单选题关于纯虚函数,下列表述中正确的是______。
单选题下面程序的结果为( )。 #include <iostream.h> void change(int a,int b) int temp; temp=a; a=b; b=temp; void main() int m,n; m=8; n=9; change(m,n); cout<<m<<""<<n<<endl; A.89 B.98 C.程序有错误 D.99
单选题以下程序的输出结果是 main( ) int a=4,b=5,e=0,d; d=! a cout<<d<<end1;
单选题下列描述正确的是
单选题下面程序的结果为( )。
#include" iostream.h"
void change(int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;
}
void main( )
{
int m,n;
m=8;
n=9;
change(m,n);
tout < < m < < " " < < n < < end1;
}
单选题有如下程序:
#include<iostream>
using namespace std;
class Mountain{
int height;
public:
Mountain(int h=0):height(h){}
virtual char* GetName()const{return"山";}
int GetHeight() const{return height;}
};
class Lushan:public Mountain{
Public:
Lushan(int d):Mountain(d){}
Char* GetName()const{return"庐山";}
};
int main(){
Mountain *p=new Lushan(1000);
cout<<p->GetName()<<"海拔"<<p->GetHeight()<<"米";
return 0;
}
运行这个程序的输出结果是______。
单选题如下程序的输出结果是main()inta=2, b=-1, c=2;if(a<B) if(b<0)c=0; else c++;cout<<c<<end1;
