cout<<*arr+1<<endl;
cout<<*(arr+1)<<endl;
cout<<arr[1]<<endl;
cout<<*arr<<endl;
第1题:
使用VC6打开考生文件夹下的工程test7_1,此工程包含一个源程序文件test7_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:
Constructor1
Constructor1
Constructor1
Destructor
Constructor2
Destructor
x=0
x=5
Destructor
Destructor
源程序文件test1_1.cpp清单如下:
include<iostream.h>
class B
{
int X;
public:
B(){X=0;cout<<"Constructorl"<<endl;}
B(int i){x=i;cout<<"Constructor2"<<endl;}
~B(){cout<<"Destructor"<<endl;}
/**********found*********/
~B(int i){cout<<i<<"be Destructor"<<endl;}
void print(){cout<<"x="<<x<<endl;}
};
void main()
{
B *ptr;
ptr=new B[2];
/**********found*********/
ptr[0]=B(0);
ptr[1]=B(5);
/**********found********/
for(int i=0; i<2;)
ptr[i].print();
delete []ptr;
}
第2题:
有如下程序:#include<iostream>using namespace std;class test{private: int a;public: test(){cout<<"constructor"<<endl;} test(int a){cout<<a<<endl;} test(const test&_test) { a=_test.a; cout<<"copy constructor"<<en+dl; } ~test(){cout<<"destructor"<<endl;}};int main(){ test A(3); rerun 0;}运行时输出的结果是
A.3
B.constructor destructor
C.copy constructor destructor
D.3 destructor
第3题:
( 27 )有如下程序:
#include
using namespace std;
class test {
private:
int a;
public:
test () {cout<< ” constructor ” <<ENDL;}
test ( int a ) {cout<<A<<ENDL;}
test ( const test & _test )
{
a=_testa;
cout<< ” copy constructor ” <<ENDL;
}
test () {cout<< ” destructor ” <<ENDL;}
};
int main ()
}
test A ( 3 )
return0;
运行时输出的结果是
A ) 3
B ) constructor
destruclor
C ) copy constructor
dstructor
D ) 3
destruclor
第4题:
以下程序的输出结果是_____。
include<iostream.h>
class object
{ private:
int val;
public:
object( ) ;
object(int i) ;
~object( ) ;};
object: :object( )
{ val=0;
cout < < "Default constructor for object" < < endl;}
object: :object(int i)
{ val=i;
cout < < "Constructor for object" < < val < < endl;}
object: :~object( )
{ cout < < "Destructor for object" < < val < < endl;}
class container{ private:
object one;
object two;
int data;
public:
container( ) ;
container(int i,int j,int k) ;
~container( ) ;};
container: :container( )
{ data=0;
cout < < "Default constructor for container" < < endl;}
container: :container(int i,int j,int k) :two(i) ,one(j)
{ data=k;
cout < < "Constructor for container" < < endl;}
container: :~container( )
{ cout < < "Destructor for container" < < endl;}
void main( )
{ container anObj(5,6,10) ;}
第5题:
已知数组arr的定义如下: intarr[5]={1,2,3,4,5};下列语句中输出结果不是2的是( )。
A.cout<<*arr+1<<endl;
B.COUt<<*(art+1)<<endl;
C.cout<<arr[1]<<endl;
D.COUt<<*arr<<endl:
第6题:
下列程序执行后的输出结果是
#included<string.h>
main( )
{ char arr[2][4];
strcpy(arr,"you");strepy(arr[1],"me");
arr[0][3]='&';
cout<<arr<<endl;
}
A.you&me
B.you
C.me
D.err
第7题:
#include <iostream>using namespace std;struct student_info{ string name; int chinese; int math; int english;};student_info student[5];void inputinfo(){ int i = 0; char a[20]; for(i = 0;i < 5;i++) { cout<<"enter the "<<i+1<<" student's information "<<endl; cout<<"enter the name"<<endl; cin>>a; student[i].name = a; cout<<"enter chinese performance :"<<endl; cin>>student[i].chinese; cout<<"enter math performance :"<<endl; cin>>student[i].math; cout<<"enter english performance :"<<endl; cin>>student[i].english; }}void outputinfo(){ int i = 0; while(i < 5) { cout<<i+1<<" student's information"<<endl; cout<<student[i].name.c_str()<<endl; cout<<"chinese "<<endl; cout<<student[i].chinese<<endl; cout<<"math "<<endl; cout<<student[i].math<<endl; cout<<"english "<<endl; cout<<student[i].english<<endl; i++; }}int avgfunction(int arr[],int n){ int i = 0; int total = 0; for(i = 0;i < n;i++) { total += arr[i]; } return total / n;}void computavg() //这里是否正确?{ int theavg = 0; theavg = avgfunction(student[i].chinese,5); }int main(){ inputinfo(); outputinfo(); computavg(); cin.get(); return 0;} 帮我找出错误 然后改过来 择优为满意答案 不分先后
第8题:
( 20 )已知数组 arr 的定义如下:
int arr[5] = {1,2,3,4,5};
下列语句中输出结果不是 2 的是
A ) cout << *arr+1 <<endl;
B ) cout << *(arr+1)<<endl;
C ) cout << arr[1] <<endl;
D ) cout << *arr <<endl;
第9题:
有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*') cout.width(6); cout.fill('#') cout<<123<<endl; return 0; } 执行后的输出结果是
A.###123
B.123###
C.***123
D.123***
第10题:
下列程序的输出结果是( )。 #ificlude<iostream> using namespace std; int main() { cout.fill('*'); cout.width(5); cout<<oct<<100<<endl; return 0; }
A.**100
B.**144
C.100**
D.144**