my program runs fine and i am able copy the object however when i used the copy assignment (=) it still runs fine .why is it not giving error? : this is my code.i didnt overload the (=) operator but still it runs fine in codeblocks.however when i ran this code on c++ shell it compiled succesfully however  the output was blank .can somebody please explain me that why is it running fine in codeblocks even though i didnt write the code for the copy assignment . 
also another question...

if in line 1 i change the return type to string instead of string& it displays an error (about temporary variable) but if i change the code of line 2 to dummy(dummy& abc : ptr(new string (abc.print())) the program runs fine (despite the return type of line 1 being string)
why is it so?





    class dummy{
    string *ptr;
    public:
    dummy(string ab) {ptr=new string; ptr=&ab;}
    ~dummy (){delete ptr;}
    string& print(){return *ptr;} //line1
    dummy (dummy& abc){ptr= new string; ptr=&(abc.print());} //line2
    dummy (){};
    };

    int main()
    {
    dummy x("manzar");
    dummy y;
    y=x;

    cout<<x.print();
    cout<<"\n"<<y.print ();
    }



i didnt expected it to run fine however it is working fine.it is copying the content from x to y.