更多"下面程序有注释的语句中,错误的语句是( )。 #include <"的相关试题:
[单项选择]下面程序有注释的语句中,错误的语句是( )。
#include <iostream>
using namespace std;
class A
int a;
public:
void show A( )cout<<"this is A!";
;
class B:public A
int b;
public:
void show B( )cout<< "this is B!";
;
void main( )
A ia,*piA;
B ib,*piB;
piA=ia; //第一个测试语句
piA=&ib; //第二个测试语句
piA->showA( ); //第三个测试语句
piA->showB( ); //第四个测试语句
A. 第一个测试语句
B. 第二个测试语句
C. 第三个测试语句
D. 第四个测试语句
[填空题]下列程序的输出结果为2,请将程序补充完整。
#include <iostream>
using namespace std;
class Base
{
public:
【12】 void fun( ) {cout<<1;}
};
class Derived: public Base
{
public:
void fun( ) {cout<<2; }
};
int main( )
{
Base *p=new Derived;
p->fun( );
delete p;
return 0;
}
[单项选择]应在下列程序画线处填入的正确语句是 ( )。
#include <iostream>
using namespace std;
clas Base
public:
void fun( )
cout<<"Base::fun"<<end1;
;
class Derived : public Base
void fun( )
________________//显示调用基类的函数 fun( )
cout<<"Derived::fun"<<end1;
;
A. fun();
B. Base.fun(); C) Base::fun(); D) Base->fun();
[单项选择]有以下程序:
#include <iostream>
#include <math>
using namespace std;
class point
private:
double x;
double y;
public:
point(double a,double b)
x=a;
y=b;
friend double distance(point a,point b) ;
;
double distance(point a,point b)
return sqrt ((a.x-b.x)* (a.x-b.x)+(a.y-b.y)*(a.y-b.y));
int main ( )
point pl(1,2);
point p2 (5, 2);
cout<<distance (pl,p2) <<end1;
return 0;
程序运行后的输出结果是()
A. 1
B. 5
C. 4
D. 6
[单项选择]下面程序的功能是( )。
#include <iostream>
#include <string>
using namespace std;
int main ( )
int i=1, n=0;
char s[80],*p;
p=s;
strcpy(p,"It is a book..");
for (; *p !=’ /0’ ;p++)
if(*p==’’)
i=0;
else if (i==0)
n++; i=1;
cout<<"n=" <<n<<end1;
return 0;
A. 统计字符串中的单词个数
B. 统计字符串中的空格个数
C. 统计字符串中的字母个数
D. 统计字符串中的全部字符个数
[单项选择]下面程序的输出结果是( )。
#include<iostream>
#include<math.h>
using namespace std;
class point
private:
double x;
double y;
public:
point(double a,double b)
x=a;
y=b;
friend double distances(point a,point b);
;
double distances(point a,point b)
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
int main( )
point p1(1,2);
point p2(5,2);
cout<<distances(p1,p2)<<end1;
return 0;
A. 2
B. 4
C. 8
D. 16
[填空题]下面程序的执行结果是 【15】
#include <iostream>
#include <iomanip>
using namespace std;
void main( )
{
cout<<setfill(’x’)<<setw(10);
cout<<"Hello"<<end1;
}
[填空题]下面程序的执行结果是 【15】 。
#include <iostream>
#include <iomanip>
using namespace std;
void main( )
cout<<setfill(’x’)<<setw(10);
cout<<"Hello"<<end1;
[填空题]下面程序的执行结果是 【15】
#include <iostream>
#include <iomanip>
using namespace std;
void main( )cout<<setfill(’x’)<<setw(10);
cout<<"Hello"<<end1;
[单项选择]下面程序的输出结果是( )。 #include<iostream> #include<string> using namespace std; void main( ){ charp1[10],p2[10]; strcpy(p1,"abc"); strcpy(p2,"ABC"); charstr[50]="xyz"; strcpy(str+2,strcat(p1,p2)); cout<<str; }
A. xyabcABC
B. yzabcABC
C. xyzabcABC
D. zabcABC
[单项选择]下面程序的输出结果是( )。
#include<iostream>
#include <math.h>
using namespace std;
class point
private:
double x;
double y;
public:
point(double a, double b)
x=a;
y=b;
friend double distances(point a,point b);
;
double distances(point a,point b)
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
int main( )
point p1 (1,2);
point p2(5,2);
cout<<distances(p1 ,p2)<<end1;
return 0;
A. 2
B. 4
C. 8
D. 16
[单项选择]下面程序的输出结果是 #include<iostream.h> #include<string.h> void main( ) { char p1[10],p2[10] strcpy(p1,"abc"); strcpy(p2,"ABC"); char str[50]="xyz"; strcpy(str+2,strcat(p1,p2)); cout<<str; }
A. xyzabcABC
B. zabcABC
C. xyabcABC
D. yzabcABC
[单项选择]下面程序的输出结果是
#include<iostream.h>
#include<string.h>
void main( )
char p1[10],p2[10]
strcpy(p1,"abc");
strcpy(p2,"ABC");
char str[50]="xyz";
strcpy(str+2,strcat(p1,p2));
cout<<str;
A. xyzabcABC
B. zabcABC
C. xyabcABC
D. yzabcABC