题目内容

已知: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;}

程序填空。下列函数检查给定的字符串左括号‘(’和右括号‘)’的使用是否合法。分别条件是:左括号‘(’的个数应与右括号‘)’的个数相同;右括号的个数在任何时候均不得超过左括号‘(’的个数;若字符串同时满足上述两个条件,函数返回值1,否则返回值0。 请填空:int check (char *s) {int L=0,R=0;while( ___1___ ){if(*s==’(‘ ) L++;else if(*s==’)’){ R++;if( __2___) return 0;}s++ ;}return (___3____);}

答案查题题库