更多"main函数中发生编译错误的语句是______。 #include<"的相关试题:
[填空题]main函数中发生编译错误的语句是 【12】 。
# include <iostream. h>
class A
{
public:
int a;
const int b:
A( ) :a(10) ,b(20) {
void fun( ) const
{
cout<<"a="<<a<<"/tb="<<b<<end1;
}
};
void main( )
A obj1;
const A * ptr = new A:
ptr = &obj1;
ptr->a=lO0;
ptr->fun( ),
}
[填空题]main函数中发生编译错误的语句是______。
#include<iostream.h>
class A
{
public:
int a;
const int b;
A( ):a(10),b(20){}
void fun( )const
{
cout<<"a="<<a<<"/tb="<<b<<endl;
}
};
void main( )
{
A obj1;
const A*ptr=new A;
ptr=&obj1;
ptr->a=100;
ptr->fun( );
}
[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为 【8】 。
# include<iostream.h>
class test
{
private:
int num;
public:
test(int)
void show( );
};
test: :test(int n){ num=n;}
test:: show( ) { cout<<num<<end1; }
void main( )
{
test T(10);
T. show ( );
}
[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为 【8】 。
# include<iostream.h>
class testprivate:
int num;
public:
test(int)
void show( );
;
test: :test(int n) num=n;
test:: show( ) cout<<num<<end1;
void main( ) test T(10);
T. show ( );
[填空题]如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。
#include<iostream.h>
class test
private:
int hum;
public:
test(int);
void show( );
;
test::test(int n)num=n;
test::show( )cout<<num<<endl;
void main( )
test T(10):
T.show( );
[填空题]完成下列类的构造函数,初始化语句为______。
#include<iostream.h>
class Test
private:
int x,y;
public:
void Test(int initx,int inity)
______
void printx( )cout<<x<<"-"<<y<<"="<<x-y;
;
void main( )
Test x(300,200);
x.printx( );
[单项选择]若有如下语句
#include
void main( )
{
int x=3;
do{
x=x-2;
cout<<x;
}while(!(--x));
}
则上面程序段
A. 输出的是1
B. 输出的是1和-2
C. 输出的是3和0
D. 是死循环
[单项选择]函数的值通过rerurn语句返回,下面关于return语句的形式描述错误的是
A. return表达式;
B. return(表达式);
C. 一个return语句可以返回多个函数值
D. 一个return语句只能返回一个函数值
[填空题]
以下程序运行后的输出结果是()。
#include
#include
#include
main( )
{ char *p;int i;
p=(char*)malloc(sizeof(char)*20);
strcpy(p,"welcome");
for(i=6;i>=0;i--) putchar(*(p+i));
printf("/n"); free(p);
}
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为 【12】 。
#include<iostream, h>
#include<string. h>
template<class T>
T min(T a, T b)
return(a<b a:b);
char * min(char * a, char * b)
__________________________
void main( )
double a=1.23,b=3.45;
char s1[]="abcd",s2[]="erg";
cout<<min(a, b)<<min(s1,s2)<<end1:
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为 【12】 。
#include<iostream, h>
#include<string. h>
template<class T>
T min(T a, T b)
{
return(a<b a:b);
}
char * min(char * a, char * b)
{
__________________________
}
void main( )
{
double a=1.23,b=3.45;
char s1[]="abcd",s2[]="erg";
cout<<min(a, b)<<min(s1,s2)<<end1:
}
[填空题]类class one 在声明func 成员函数时发生错误,出错原因是 【9】 。
Class one
{
private:
int a;
public:
void func(two& )
};
class two
{
private:
int b;
friend void one: :func(two & );
};
void one: : func(two& r)
a=r.b;
}
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#include<iostream.h)
#include(string.h>
template(class T)
T min(T a,T b)
{
return(a<ba:b);
}
char*min(char*a,char*b)
{
}
void main( )
{
double a=1.23,b=3.45;
chars1[]=”abcd”,s2[]=”efg”;
cout<<min(a,b)<<rain(s1,s2)<(endl;
}
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#include<iostream.h>
#include<string.h>
template<class T>
T min(T a,T b)
return(a<b a:b);
char*rain(char*a,char*b) ______
void main( )
double a=1.23,b=3.45;
char s1[]="abed",s2[]="efg";
cout<<min(a,b)<<min(s1,s2)<<endl;
[单项选择]若函数中有定义语句:int k;,则______。
A. 系统将自动给k赋初值0
B. 这时k中的值无定义
C. 系统将自动给k赋初值-1
D. 这时k中无任何值
[单项选择]有以下程序
#include
main( )
{FILE *fp; int i;
char ch[]="abcd",t;
fp=fopen("abc.dat", "wb+");
for(i=0;i<4;i++)fwrite(&ch[i],1,1,fp);
fseek(fp,-2L,SEEK_END);
fread(&,1,1,fp);
fclose(fp);
printf("%c\n",t);
}
程序执行后的输出结果是【 】。
A. d
B. c
C. b
D. a