0
Can u explain me?
I don't understand what is happening here Mystring is class has only single attribute char * str; Also it has all ctors(default, overloaded, copy, move, dtor...) In main.cpp Mystring obj(Mystring("This is string")); What is happening here?👆👆👆
1 Odpowiedź
+ 3
Well, first you construct a temporary instance of Mystring using "This is string" as argument for the overloaded constructor, and afterwards, you construct a permanent instance from the temporary one. Since the first instance is about to be destroyed, this would invoke the move constructor. However, your compiler will probably optimize the line to a single call to the overloaded constructor.