网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

类中包含了一个静态成员函数,则main函数中和P.fl(P);语句具有同样功能的语句为______。

include<iostream.h>

class M

{

public:

M(int A){A=a;B+=a;}

static void fl(M m);

private:

int A;

static int B;

};

void M::f1(M m)

{

cout<<"A="<<m.A<<endl;

cout<<"B="<<m.B<<endl;

}

int M::B=10;

void main( )

{

M P(5);

P.f1(P);

}


参考答案

更多 “ 类中包含了一个静态成员函数,则main函数中和P.fl(P);语句具有同样功能的语句为______。include<iostream.h>class M{public:M(int A){A=a;B+=a;}static void fl(M m);private:int A;static int B;};void M::f1(M m){cout<<"A="<<m.A<<endl;cout<<"B="<<m.B<<endl;}int M::B=10;void main( ){M P(5);P.f1(P);} ” 相关考题
考题 请补充main函数,该函数的功能是:输出一个3×3的矩阵,要求必须使用行指针表示输出变量。注意;部分源程序给出如下.请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。试题程序:include<s tdio. h>main(){static int array[3] [3]={{9,8,7}, {6,5,4}, (3,2,1}};iht (*p) [3],j,i;p=【 】clrscr ();for (i=0; i<3; i++){printf (" \n\n" );for (j=0; j<3; j++)printf("%4d",【 】);}}

考题 请补充main函数,改函数的功能是,把一个二维字符数组每行字符串最大的字符拷贝到字符数组s中。例如,如果str[3]={"efjh","cfimls","owys"},则s;"hsy"。注意:部分源程序给出如下.请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。试题程序:inc lude<stdio, h>main(){int i=0;char *str [3] ={ "efjh", "efknls","owys" };char **p;char s [8];clrscr 0;【 】;for (i=O; i<3; i++){s [i] =*p [i];while (*p [i] ){if (S [i] <*p [i] )s [i] =*p[i];【 】;}}【 】;printf(" new string \n");puts (s);}

考题 请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<conio.h>define LEN 80main(){char str1[LEN],str2 [LEN];char *p1=str1,*p2=str2;int i=0,j=0;clrscr();printf("Enter the string:\n");scanf(【 】);printf("***the origial string***\n");while(*(p1+j)){printf("【 】",*(p1+j));j++;}for(i=0;i<j;i+=2)*p2++=*(str1+i);*p2='\0';printf("\nThe new string is:%s\n", 【 】 );}

考题 请补充main函数,该函数的功能是:打印届1~1000中满足:个位数字的立方等于其本身所有数。本题的结果为;1 64 125 216 729注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数main的横线上填入所编写的若干表达式或语句。试题程序:include <stdio .h>main ( ){int i,g;clrscr ();for (i=1; i<1000; i++){g=【 】;if(【 】)printf ("%4d", i);}}

考题 请编写一个函数maxofarray(atype*p,int count),该函数从一个数组中找出其中的最大元素,并且数组中可以存放多种数据类型的元素。注意:部分源程序己存在文件test42_2.cpp中。请勿修改主函数main和其他函数中的任何内容,仅在函数maxofarray的花括号中填写若干语句。文件test42_2.cpp清单如下:include<iostream.h>include<string.h>include<conio.h>template<class atype>void maxofarray(atype* p,int count){}void main (){int len=5;char *p1;cout<<"the char type array and it's length is 5:\n";cout<<"the array element is a b c d e\n";p1=new char[len];for (int i=0;i<len;i++)p1[i]='a'+i;maxofarray(p1,len);}

考题 请补充main函数,该函数的功能是:从键盘输入若干字符放到一个字符数组中,当桉回车键时结束输入,最后输出这个字符数组中的所有字符。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<ctype.h>main(){int i=0;char a [81];char *p=s;clrscr ();printf{" Input a string \n");for (i=0; i<80; i++){s [i] =getchar ( );if (s [i]=='\n')【 】;}s[i]=【 】printf(" display the string \n");while (*p)putchar (【 】);}

考题 已知一个类A,其中Fun()函数是类A的一个成员函数,A*p,a;p=a;,则下面语句正确的是( )。A.语句p=a;是把对象a赋值给指针变量pB.语句A*p,a;p=a;调用两次类A的构造函数C.对语句*p.fun();的调用是正确的D.语句 p->fun();和语句 a.fun();等价

考题 类中包含了一个静态成员函数,则main函数中和P.f1(P);语句具有同样功能的语句为______。include<iostream.h>class M{public:M(int A){A=a;B+=a;}static void f1(M m);private:int A;static int B;};void M::f1(M m){cout<<“A=“<<m.A((end1;cout<<“B=”<<m.B<<en

考题 关于this指针,下列说法正确的是:A.普通成员函数隐含了一个this指针B.静态成员函数隐含了一个this指针C.静态成员函数可以访问静态数据成员和静态函数成员D.静态成员函数不能访问非静态成员函数和非静态数据成员E.非静态成员函数可以任意地访问静态成员函数和静态数据成员。