Rahul wrote:
Hi Everyone,
I know that implicit conversion is invoked for the following case,
class A
{
public: A(int n)
{
...
}
};
A obj = 2;
But is any temp objects created? Is the 2 used to create a temp
object and then is the temp object assigned to the the actual object
obj?
The semantics are such that a temporary object is created. However,
the Standard allows the compiler to forgo creation of a temporary in
such case and construct 'obj' as if you wrote
A obj(2);
The copy-constructor in 'A' has to still be accessible, though.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask