Hi all,
I don't quite understand the program print the following output.
class D
{
public:
D(int j):i(j){printf("default %d\n", i);};
D(const D& d):i(d.i){printf("copy %d\n", i);};
private:
int i;
};
int main(int argc, char** argv)
{
D d = 2;
D d1 = D(23);
}
output:
default 2
default 23
I expect the copy constructor should be called after the temp object is created.
But why no "copy" is displayed?