#include<iostream>
#include<cmath>
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<<distance(p1);
return 0; //③
}
下列叙述中正确的是
A.程序编译正确
B.程序编译时语句①出错
C.程序编译时语句②出错
D.程序编译时语句③出错
[单选题]有如下程序:#include<iostream>#include<cstring>using namespace std;class XCD{char*a;int b;public:XCD(char;l:aa,int bB){a=flew char[strlen(aA)+1];strcpy(a,aA);b=bb;}char*lE Geta(){return a;}int Getb(){return b;}};int main(){char*pl=”abcd”.*p2=”w
[单选题]有如下程序:#include<iostream>#include<cstring>using namespace std;class XCF{int a;public:XCF(int aa=O):a(aA){cout<<”1”;}XCF(XCF&X){a=x.a;cout<<”2”;}~XCF(){cout<<at}int Geta(){return at}};int main(){XCF dl(5),d2(d1);XCF半pd
[单选题]有如下程序:#include<iostream>#include<iomanip>using namespace std;int main(){cout<<setw(10)<<setfill(’X’)<<setprecision(8)<<left;cout<<12.3456793<<______<<98765;return 0;}若程序的输出是12.345679x98765xxxxx,则划
[单选题]有如下程序:#include<iostream>#include<iomanip>using namespace std;int main(){int S[]={123,234};cout<<right<<setfill(‘*’)<<setw(6);for(int i=0;i<2;i++){cout<<s[i]<<endl;}retum 0;}运行时的输出结果是A.123B.***123C.***123D.
[单选题]( 28 )有如下程序:#include<iostream>#include<cstring>using namespace std;class XCF{int a;public:XCF ( int aa=0 ) : a ( aa ) {cout<<"1" ; }XCF ( XCF& x ) {a=x .a; cout<<"2" ; )~XCF () {cout<<a;}int Geta () {return a;}};
[单选题]( 27 )有如下程序:#include<iostream>#include<cstring>using namespace std;class XCD{char* a;int b;public:XCD ( char* aa, int bb ) {a=new char[strlen ( aa ) +1];strcpty ( a,aa ) ;b=bb;}C.har* Geta () {return a; )int Getb () { return b;}};int main
[单选题]( 34 )有如下程序:#include<iostream>#include<iomanip>Using namespace std;int main(){int s[]={123, 234};cout<<right<<setfill('*')<<setw(6);for(int i=0; i<2; i++) { cout<<s[i]<<endl; }return 0;}运行时的输出结果是A. ) 123
[单选题]有如下程序:include<iostream>usingnamespacestd;classAA{public;A.A( ){cOUt<<1;)};classBB:publicAA{intk;public:B.B( ):k(0){tout<<12;}B.B(intn):k(n)(cout<<3;)};intmain( ){B.Bb(4),c;return0;}运行时的输出结果是( ).A.1312B.132C.32D.1412
[单选题]有如下程序:include<iostream>usingnamespacestd;classC1{public:~C1( ){cout<<1;)};classC2:publicC1{public:~C2( ){cout<<2;)};intmain( ){C.2cb2;C.1*cb1:return0;}运行时的输出结果是( )。A.121B.21C.211D.12
[单选题]有如下程序:include<iostream>usingnamespacestd;classXA{inta;public:staticintb;XA(intaa):a(aa){b++;}~XA( ){}intget( ){returna;}};intXA::b=0intmain( ){XAd1(1),d2(3);cout<<d1.get( )+d2.get( )+XA::b<<endl;return0;}运行时的输出结果是( )。A.5B.6C.7D.8