填空题
若要把类 FriendClass 定义为类 MyClass 的友元类,则应在类 MyClass 的定义中加入语句
【11】
。
【参考答案】
friend FriendClass;
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
有以下程序: #include <iostream> using namespace std; class Base private: int a,b; public: Base(int x, int y) a=x; b=y; void Show() cout<<a<< ’,’ <<b<<end1; ; class Derived : public Base private: int c; public: Derived(int x, int y, int z) : Base(x,y),c(z) void Show() cout<<c<<end1; ; int main() Base b(50,50),*pb; Derived d(10,20,30); pb=&d; pb->Show(); return 0; 运行后的打印结果为 【14】
点击查看答案&解析
填空题
有以下程序: #include <iostream> using namespace std; class MyClass public: MyClass(); ~MyClass(); static int s; void SetValue(int val); ; int MyClass::s=0; MyClass::MyClass() s++; void MyClass::SetValue(int val) s=val; int main() MyClass my[3],*p; p=my; for(int k=0;k<3;k++) p->SetValue(k+1); p++; cout<<MyClass::s<<end1; return 0; 运行后的输出结果是 【13】 。
点击查看答案&解析
相关试题
有如下的类的模板定义: template <clas...
设文件temp.txt 已存在,则以下的打印结...