题目内容

下列关于静态成员的描述中错误的是( )

A. 静态数据成员要在类体外进行初始化
B. 静态成员属于类而不属于对象
C. 对静态成员的访问不受访问权限的限制
D. 静态成员是静态存储的

查看答案
更多问题

下列有关一个类的友元函数的叙述中,正确的( )

A. 允许在类外访问类中除私有成员以外的所有成员
B. 允许在类外访问类中的任何成员
C. 友元也是该类的成员
D. 友元的声明必须被放在该类的公有部分

请将如下程序补充完整,使程序的输出结果为“10-6”#include using namespace std;class Test {int x,y;public:Test(int i, int j) : [1] { }int get() const {return x-y;}int get(){return x+y;}};int main(){Test t1(4,6);[2] t2(2,8);cout<

下列程序通过把类Distance定义为类Point的友元类来实现计算两点之间距离的功能。请完成该程序。(假设没有给出坐标的点为原点)#include #include using namespace std;class Point{ public:[1] ;Point( [2] ){ X=a; Y=b;}void Print(){ cout<<”X=”<

写程序运行结果.#include using namespace std;class A{int i,j;static int c;public:A(int a=0,int b=0) { i=a; j=b; c++; }~A() { c--; }static void f() { cout<<"c="<

答案查题题库