填空题

非成员函数应声明为类的 【10】 函数才能访问这个类的private成员。

【参考答案】

友元
<上一题 目录 下一题>
热门 试题

填空题
下列程序的输出结果为: Object id=0 Object id=1请将程序补充完整。 #include <iostream> using namespace std; class Point public: Point(int xx=0,int yy=0) X=xx;Y=yy;countP++; ~Point() countP--; int GetX() return X; int GetY() return Y; static void GetC0 cout << Objectid= <<countp<<end1; private: int X,Y; static int countP; ; 【9】 静态数据成员的初始化 int main() Point:: GetC(); Point A(4,5); A.GetC(); return 0;
填空题
下面是一个栈类的模板,其中push函数将元素i压入栈顶,pop 函数弹出栈顶元素。栈初始为空,top值为0,栈顶元素在stack[top-1)中,在下面横线处填上适当语句,完成栈类模板的定义。 template <class T> class Tstack enumsize=1000; T stack[size]; int top; public: Tstack():top(0) void push(const T&i) if (top<size) stack[top++]=i; T pop() if(top==0) exit(1); 栈空时终止运行 return 【15】 ; ;
相关试题
  • 多数运算符既能作为类的成员函数重载,也能...