填空题
【13】
允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回位能取任意类型。
【参考答案】
类模板
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
以下程序运行后的输出结果是 【10】 #include <iostream> #include <string> using namespace std; class Y; class X int x; char *strx; public: x(int a,char *str) x=a; strx=new char[strlen(str)+1]; strcpy(strx,str); void show(Y &oB) ; ; class Y private: int y; char *stry; public: Y(int b,char *str) y=b; stry=new char[strlen(str)+1]; strcpy(stry, str); friend void X::show(Y &oB) ; ; void X::show(Y &oB) cout<<strx<< , ; cout<<ob.stry<<end1; int main() X a(10, stringX ); Y b(20, stringY ); a.show(B) ; return 0;
点击查看答案&解析
填空题
下面程序的运行结果是 【9】 。 #inChlde<iOStream> using namespace std; class count static int n; public: count() n++; static int test() for(int i=0:i<4;i++) n++; return n; ; int count::n=0; int main() cout<<COUnt::test()<< ; count c1, c2; cout<<count::test()<<end1; return 0;
点击查看答案&解析
相关试题
下面是复数类complex的定义,其中作为友元...
若有以下程序: #include<iostream> u...