In c++ we have default copy constructor ,which is called when we use
statement like e2=e;ie when object are of same class type.

On Aug 28, 3:29 pm, ravi maggon <[email protected]> wrote:
> Hi
> Can you explain the below mentioned code. As far as I know we need to
> overload = operator in order to equate object of a class and below code
> should give error. But it is running perfectly on gcc compiler. Please
> correct  me if I am wrong at some point.
>
> #include<iostream>
> using namespace std;
>
> class emp
> {
>       public:
>              char *n;
>              int age;};
>
> int main ()
> {
>     emp e={"xyz",21};
>     emp e2;
>     e2=e;
>     printf("%d",e2.age);
>     system("pause");
>
> }
>
> --
>
> Regards
> Ravi Maggon

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

Reply via email to