填空题
类中包含了一个静态成员函数,则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<<end1;
int M::B=10;
void main()
M P(5);
P.f1(P);
【参考答案】
M::f1(P);。
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
对于下面定义的类MyClass,请在函数f()中添加对象成员把n的值修改为50。 Class MyClass Public: MyClass(int x)n=x;) Void SetNum(int nl)n=nl; private: int n; ; int f() MyClass*ptr=new MyClass(45);
点击查看答案&解析
填空题
在下列的程序的横线处填上适当的语句,使该程序的输出为12。 #include<iostream.h> using namespace std; class Base public: int a,b; Base(int i)a=i; ; class Derived:public Base int a; public: Derived(int x):Base(x),b(x+1); void show() ______; 输出基类数据成员a的值。 cout<<b<<endl; ; void main() Derived d(1); d.show(); return 0;
点击查看答案&解析
相关试题
C++语句constchar *constp=”hello”...
在MyClass类的定义中,对赋值运算符=进行...
有以下程序: #include<iostream> usi...
下列程序的输出结果是______。 #in...