以下程序的输出?
null
#include <iostream> using namespace std; class Test2 { int y; }; class Test { int x; Test2 t2; public : operator Test2 () { return t2; } operator int () { return x; } }; void fun ( int x) { cout << "fun(int) called" ; } void fun ( Test2 t ) { cout << "fun(Test 2) called" ; } int main() { Test t; fun(t); return 0; } |
(A) 乐趣(int)呼叫 (B) 乐趣(测试2)打电话 (C) 编译器错误:对fun()的调用不明确 答复: (C) 说明: 类测试有两个重载的转换运算符,int和Test2。int和Test2有两个fun()。 这个问题的小测验
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END