@all: thanks
On Sun, Aug 28, 2011 at 4:55 PM, rahul vatsa <[email protected]> wrote:
> c++ provides a few default member functions for your class if you don't
> declare them urself, this includes copy constructor & assignment(=)
> operator.
>
> In your program,
> emp e={"xyz",21}; // the default copy constructor is invoked
> e2=e; // here the default assignment operator is invoked
>
>
>
> On Sun, Aug 28, 2011 at 7:14 AM, prateek gupta <
> [email protected]> wrote:
>
>> 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.
>>
>>
> --
> 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.
>
--
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.