更多"main函数中发生编译错误的语句是 【12】 。 # in"的相关试题:
[填空题]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( );
[填空题]参照函数模板的写法,完成非模板函数的定义,语句为______。
#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[]="efg";
eout<<min(a,b)<<min(s1,s2)<<endl;
[填空题]完成下列类的构造函数,初始化语句为 【13】 。
#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( ); }
[填空题]完成下列类的构造函数,初始化语句为 【13】 。
#include <iostream. h>
class Testprivate:
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<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<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 <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. 第四个测试语句
[简答题]完成下面类中成员函数的定义。
#include<iostream>
#include<string>
using namespace std;
class str
private:
char*st;
public:
str(char*a)
set(a);
str&operator=(______)
delete st;
set(a.st);
return*this;
void show( )cout<<st<<endl;
~str( )delete st;
void set(char*s)//初始化st
______
strcpy(st,s);
;
void main( )
str s1("he"),s2("she");
s1.show( ),s2.show( );
s2=s1;
s1.show( ),s2.show( );
[判断题]C程序总是从main( ) 函数的第一条语句开始执行的。 ( )
[简答题]完成下面类中成员函数的定义。
#include<iostream.h>
#include<iomanip.h>
class Arr
protected:
float*p;
int n;//数组大小(元素个数)
public:
Arr(int sz=10)
n=sz;
p=new float[n];
~Arr(void)
______
int Getn(void)const
return n;
float*operator[](int i)
______
void Print( );
;
void Arr::Print( )
int i;
for(i=0;i<this->Getn( );i++)
if(i%10= =0)
cout<<endl;
cout<<setw(6)<<p[i];
cout<<endl:
void main( )
Arr a(20);
for(int i=0;i<a.Getn( );i++)
a[i]=i*2;
a.Print( );
[填空题]程序
#include" iostream.h"
void main( )
{
int i=10;
jnt j=5;
cout < < j+i++ < < end1;
}
的结果为 【7】