C++类和对象问题6

关于以下程序,以下哪项是正确的

null

#include <iostream>
class Test
{
public :
int i;
void get();
};
void Test::get()
{
std::cout << "Enter the value of i: " ;
std::cin >> i;
}
Test t; // Global object
int main()
{
Test t; // local object
t.get();
std::cout << "value of i in local t: " <<t.i<< '' ;
::t.get();
std::cout << "value of i in global t: " <<::t.i<< '' ;
return 0;
}


贡献者 普拉瓦西会面 (A) 编译器错误:不能有两个具有相同类名的对象 (B) 第行出现编译器错误“::t.get();”

(C) 编译和运行良好 答复: (C) 说明: 上述程序编译并运行良好。像变量一样,可以创建两个同名的对象&在不同的范围内。 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享