已知:p是一个指向类A公有数据成员m的指针,a是类A的一个对象。如果要给该对象的m赋值为5,正确的是( )。
A. a.p=5;
B. a->p=5;
C. a.*p=5;
D. *a.p=5;
以下类模拟实现c++标准库string类的基本功能,实现效果见主函数中的注释。请填空。。(语句结束分号不用再写)#include#includeusingnamespacestd;classString{public:String(){Length=0;——1——;}String(constchar*str){Length=strlen(str);—2—;strcpy(Buffer,str);}voidSetc(intindex,charnewchar){if(index>0&&index<=Length)——3——;};voidPrint()const{if(Buffer==0)cout<<”emptystring.\n”;elsecout<
写结果。#include#includeusing namespace std;int main() {char str[100]=”Iam20yearsold.” ;char *ptr=str;int total,cap,sma,num,oth;total=cap=sma=num=oth=0;cin.get(ptr,100);while(*ptr!=0) {total++;if(*ptr>='A'&&*ptr<='Z')cap++;else if(*ptr>='a'&&*ptr<='z')sma++;else if(*ptr>='0'&&*ptr<='9')num++;else oth++;ptr++;}cout<
写结果。#includeusing namespace std;char *func(char *q,char c) {while(*q!=c&&*q!='\0’)q++;if(*q==c)return q;elsereturn NULL; }int main() {char a[15]=”ABCDEF“,b=‘D’;if(*func(a,b)!=NULL)cout<<”Y“;elsecout<<"F";return 0;}