A
arnuld
STATEMENT: define functions f(char), g(char&) and h(const char&). call
them with arguments 'a', 49, 3300, c, uc and sc where:
c = char
uc = unsigned char
sc = signed char
which calls are legal ?
which calls cause compiler to introduce temporary variable ?
ANSWER:
f('a') : legal
f(49) : legal but implicit conversion to from INT to CHAR
f(3300) : overflow in implicit conversion
f(c) : legal
f(uc) : legal but implicit conversion from "unsigned char"
to "char"
f(sc) : legal but implicit conversion from "signed char" to
"char"
in case of "g(char&)", only "g(c), g(uc) and g(sc)" will be legal
only the calls to "h(const char&)" will result inthe creation of a
"temporary variable". these will be legal:
h('a')
h(49)
h(3300)
may i know whether i am right or wrong ?
them with arguments 'a', 49, 3300, c, uc and sc where:
c = char
uc = unsigned char
sc = signed char
which calls are legal ?
which calls cause compiler to introduce temporary variable ?
ANSWER:
f('a') : legal
f(49) : legal but implicit conversion to from INT to CHAR
f(3300) : overflow in implicit conversion
f(c) : legal
f(uc) : legal but implicit conversion from "unsigned char"
to "char"
f(sc) : legal but implicit conversion from "signed char" to
"char"
in case of "g(char&)", only "g(c), g(uc) and g(sc)" will be legal
only the calls to "h(const char&)" will result inthe creation of a
"temporary variable". these will be legal:
h('a')
h(49)
h(3300)
may i know whether i am right or wrong ?