更多"有如下程序: #include <iostream.h> #inc"的相关试题:
[简答题]有如下程序
#include
#include
using namespace std;
class MyClass{
public:
MyClass( ){cout<<’A”;}
MyClass(char c {cout<A. A.ABX
B.ABXB
C.AXB
D.AXBB
[单项选择]有如下程序:
#include
#include
using namespace std;
class MyString{
public;
char str[80];
MyString(const char*s) {strcpy(str,s);}
MyString&operator+=(MyString a){
strcat(str,a.str);
return*this;
}
};
ostream&operator<<(ostream&s,const MyString&z){return s << z.str}
int main( ){
MyString x("abc"),y("cde");
cout<<(x+=y)<A. abc
B. cde
C. abcde
D. abccde
[单项选择]有如下程序 #include <iostream> #include <iomanip> using namespace std; class MyClass { public: MyClass( ) { cout<<’A’; } MyClass(char c){ cout<<c; } ~MyClass( ){ cout<<’B’; } }; int main( ) { MyClass p1,*p2; p2=new MyClass(’X’); delete p2; return 0; } 执行这个程序屏幕上将显示输出
A. ABX
B. ABXB
C. AXB
D. AXBB
[单项选择]有如下程序:
#include
using namespace std;
class Boat;
class Car{
public:
Car(int i):weight(i){ }
friend int Total(const Car &c.const Boat &b); //①
private:
int weight;
};
class Boat{
public:
Boat(int i):weight(i){ }
friend int Total(const Car &c,const Boat &b);
private:
int weight;
};
int Total(const Car &c,const Boat &b){ //②
return c.weight+b.weight;
}
int main( ){
Car c(10);
Boat b(8);
cout<<"The total weight is"<A. 程序编译正确
B. 程序编译时语句①出错
C. 程序编译时语句②出错
D. 程序编译时语句③出错
[单项选择]有如下程序
#include <iostream>
#include <iomanip>
using namespace std;
int main( )
cout<<setprecision(3)<<fixed<<setfill('*')<<setw(8);
cout<<12.345<<______34.567;
return 0;
若程序的输出是:
**12.345**34.567
则程序中下划线处遗漏的操作符是( )。
[单项选择]
有如下程序:
#include
#include
using std::cout;
class Point{
public:
friend double distance(const Point &p); //p距原点的距离
Point(int xx=0,int yy=0):x (xx),Y(YY){}//①
private:
Int x,Y;
};
double distance(const Point &p) { //②
return sqrt(p.x*p.x+p.Y*p.Y);
}
int main(){
Point p1(3,4);
cout< return 0;
}
下列叙述中正确的是()
A. 程序编译正确
B. 程序编译时语句①出错
C. 程序编译时语句②出错
D. 程序编译时语句③出错
[单项选择]有如下程序
#include
using namespace std;
int i=1;
class Fun{
public:
static int i;
int value( ){return i-1;}
int value( )const{return i+1;}
} ;
int Fun::i=2;
int main( ){
int i=3;
Fun fun1;
const Fun fun2;
return 0;
}
若程序的输出结果是:
123.
则程序中下划线处遗漏的语句是【 】
A. cout<B. cout<C. cout<D. cout<