please check out the code below :
#include <iostream>
using namespace std;
struct A{
A(char* str) { cout << "default called" << endl; }
A(const A &a) { cout << "copy called" << endl; }
};
int main() {
A obj = "str";
}
the Output is :
default called
why when i initialize object ,the consturctor of temprorary object isnt called ?? doesnt
A obj = "str";
turn into
A obj = A("str") // so why consturctor of temprorary object isnt called ??
???
i know about Copy elision little bit that why copy constructor of obj
isnt called
but why cosntructor of temprorary ojbect isnt called ??
Thanks!