c**********e 发帖数: 2007 | 1 class coord {
int x, y;
public:
coord(int i, int j) {x=i; y=j;}
operator int() { return x*y; }
};
int main() {
coord o1(2,3);
int i, j;
i=o1;
j=5;
return 0;
}
a. There is an error because coord does not have an overloaded assignment
operator that returns an int.
b. There is an error because coord does not have an overloaded assignment
operator that returns an int.
c. The final value of i will be 6.
d. There is an error because the overloaded operator must have a return type
. |
I*****y 发帖数: 602 | 2 c
【在 c**********e 的大作中提到】 : class coord { : int x, y; : public: : coord(int i, int j) {x=i; y=j;} : operator int() { return x*y; } : }; : int main() { : coord o1(2,3); : int i, j; : i=o1;
|
v*****r 发帖数: 2325 | 3 it is User-defined conversions in C++, but can use a more understandable
member function.
c++ is strong type language, why allow this?
【在 I*****y 的大作中提到】 : c
|
d*****d 发帖数: 46 | 4 Agree, implicit conversion is an evil in general. An "explicit" keyword is
considering by c++...
【在 v*****r 的大作中提到】 : it is User-defined conversions in C++, but can use a more understandable : member function. : c++ is strong type language, why allow this?
|
c**********e 发帖数: 2007 | 5 Hehe, this is to test basic C++ knowledge.
【在 v*****r 的大作中提到】 : it is User-defined conversions in C++, but can use a more understandable : member function. : c++ is strong type language, why allow this?
|
v*****r 发帖数: 2325 | 6 frankly, 边边角角 knowledge. But yes if somebody knows about this without
much preparation, then his vocabulary of C++ language is huge. but his problem solving skills, algorithm design skills are not tested....
which company or what kind of company tests u about this?
【在 c**********e 的大作中提到】 : Hehe, this is to test basic C++ knowledge.
|
c**********e 发帖数: 2007 | 7 作为低手,不得不学习茴香豆的茴字的四种写法。高手就不用了。
without
problem solving skills, algorithm design skills are not tested....
【在 v*****r 的大作中提到】 : frankly, 边边角角 knowledge. But yes if somebody knows about this without : much preparation, then his vocabulary of C++ language is huge. but his problem solving skills, algorithm design skills are not tested.... : which company or what kind of company tests u about this?
|
B********e 发帖数: 1062 | 8 How can you expect a guy who don't know these questions to write serious C++
codes?
without
problem solving skills, algorithm design skills are not tested....
【在 v*****r 的大作中提到】 : frankly, 边边角角 knowledge. But yes if somebody knows about this without : much preparation, then his vocabulary of C++ language is huge. but his problem solving skills, algorithm design skills are not tested.... : which company or what kind of company tests u about this?
|
p********7 发帖数: 549 | 9 能具体解释下么?我学过符号重载啊,也用过,但是真不知道为啥答案就是6呢
++
【在 B********e 的大作中提到】 : How can you expect a guy who don't know these questions to write serious C++ : codes? : : without : problem solving skills, algorithm design skills are not tested....
|
p********7 发帖数: 549 | 10 能具体解释下么?我学过符号重载啊,也用过,但是真不知道为啥答案就是6呢
++
【在 B********e 的大作中提到】 : How can you expect a guy who don't know these questions to write serious C++ : codes? : : without : problem solving skills, algorithm design skills are not tested....
|
|
|
d*****1 发帖数: 1837 | 11 i = o1
=>
i = (int) o1
=> i = 2*3
【在 p********7 的大作中提到】 : 能具体解释下么?我学过符号重载啊,也用过,但是真不知道为啥答案就是6呢 : : ++
|
l******9 发帖数: 7 | 12 I think this is functor (function object). It is discussed in ch16 of c++
primer |
X****r 发帖数: 3557 | 13 What you think is wrong.
c++
【在 l******9 的大作中提到】 : I think this is functor (function object). It is discussed in ch16 of c++ : primer
|
N***m 发帖数: 4460 | 14 大虾帮我看看ajax小问题啊
【在 X****r 的大作中提到】 : What you think is wrong. : : c++
|
S***w 发帖数: 1014 | 15 不错 好题
【在 c**********e 的大作中提到】 : class coord { : int x, y; : public: : coord(int i, int j) {x=i; y=j;} : operator int() { return x*y; } : }; : int main() { : coord o1(2,3); : int i, j; : i=o1;
|