My question is without any copy constructor defined in the class,
how does the following statement works?
str s3(s2);
Here we are passing an object as argument
doesn't that mean we need a copy constructor(Call by ref)
A copy constructor will be created automatically if you don't declare one. It will just copy each member to the new object so s3.name and s2.name will both point to the same data. Probably not what you want.
str s1="New"; is equivalent to str s1(str("New")); but the compiler is allowed to optimize away the extra constructor call resulting in the same machine code as str s2("York");.
If you delete the copy constructor or make it private str s1="New"; will fail to compile while str s2("York"); still compiles.