预测C++程序的输出
null
#include<iostream> using namespace std; class Test { private : int x; int y; public : Test( int x = 0, int y = 0) { this ->x = x; this ->y = y; } static void fun1() { cout << "Inside fun1()" ; } static void fun2() { cout << "Inside fun2()" ; this ->fun1(); } }; int main() { Test obj; obj.fun2(); return 0; } |
(A) fun2()内部fun1()内部 (B) 内部fun2() (C) fun1()内部fun2()内部 (D) 编译错误 答复: (D) 说明: fun2()中有错误。它是一个静态函数,试图访问该指针。
此指针对静态成员函数不可用,因为可以在没有任何对象的情况下调用静态成员函数。 这个问题的小测验
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END