+ 1

Why base copy constructor is called

Refer code below: https://www.sololearn.com/compiler-playground/c4C8KhE4ef5a I am typecasting object from derived class to base class. As it has to slice object and create the base object , why copy constructor of base class is called instead of move constructor? Object is temporary so it should call move constructor, right?

18th Sep 2022, 4:51 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Réponses
+ 2
The instance `d` is an lvalue and not temporary, why should the move constructor be called?
18th Sep 2022, 10:41 AM
Shadow
Shadow - avatar
+ 1
Yes.
19th Sep 2022, 1:50 PM
Shadow
Shadow - avatar
0
My bad Casted object is rvalue...right ? Not the d..so should be doing move(d) to have move constructor call
19th Sep 2022, 11:38 AM
Ketan Lalcheta
Ketan Lalcheta - avatar