Nothing wrong with it. You need to show your actual code. I think your code might actually be calling a copy constructor.
std::cout << "Constructed with " << z << '\n';
int y = 10;
hippo x = hippo(y);
Last edited on
Thank you so much for the reply @lastchance
Sorry, The actual code cannot be shared.
Or even better, a complete test program that demonstrates the issue.
Thanks again @lastchance
The copy constructor suggestion had really worked for me. Now the code is rectified.