Consider a  class

class string
{
     char *p;
     int len;
     public:
      string(char *a);

};

string::string(char *a)
{
    length = strlen(a);
    p= new char[length +1];
    strcpy(p,a);
}

string s1,s2;
char *name ="test";
s2=name; // statement

Why does constructor gets called in statement , even though we are
just assigning it ? Also this has to be done by operator overloading
rather than a constructor

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to