第1题
A.xyzabcABC
B.zabcABC
C.xyabcABC
D.yzabcABC
第2题
#include<string.h>
voidmain()
{
charp1[10],p2[10];
strcpy(p1,"abc");
strcpy(p2,"ABC");
charstr[50]="xyz":
strcpy(str+2,strcat(p1,p2));
cout<<str;
}
A.xyzabcABC
B.zabcABC
C.xyabcABC
D.yzabcABC
第3题
A.5
B.4
C.3
D.2
第4题
< <endl; return> A、s
B、string
C、变量a的地址
D、变量p的地址
</endl;>
第5题
include<iostream>
include<string>
using namespace std;
class Word{
public:
Word(string s):str(s){}
string getStr(){retum str;}
【 】const{retum(str<w.str);}
friend ostream&operator<<(ostream&output,const W0rd&w)
{output<<w.str;return output;}
private:
string str:
};
int main(){
Word wl(”Happy”),w2(“Welcome”);
eout<<”After sorting:”:
if(w1<w2)tout<<wl<<‘ ’<<w2:
else cout<<w2<<‘ ’<<wl:
return 0;
}
第6题
辑值。程序的输出结果为: After Sorting: Happy Welcome ,请将程序补充完整。
#include <iostream>
#include <string>
using namespace std;
class Word {
public:
Word(string s) : str(s) { }
string getStr(){ return str; }
【 14 】 const { return (str<w.str); }
friend ostream& operator << (ostream& output, const Word &w)
{ output<<w.str; return output; }
private:
string str;
};
Int main(){
Word w1("Happy"),w2("Welcome");
Cout<<"After sorting: ";
if(w1<w2) cout<<w1<<' '<<w2;
else cout<<w2<<' '<<w1;
return 0;
}
第7题
第8题
第9题
第10题
关于下列程序 说法正确的是 #include <iostream> #include <fstream> #include <string> using namespace std; class A {public: A(const char *na) {strcpy(name,na);} private: char name[80]; }; class B:public A { public: B(const char *nm):A(nm){ } void show(); }; void B::show() { cout<<"name:"<> < <endl; } void main() { b b1("b"); b1.show();> A、能正常执行
B、不能正常执行 只能将第九行private:改为public:才能正常运行
C、不能正常执行 只能将第九行private:改为protected:才能正常运行
D、不能正常执行 B,C两项都行
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!