@balaji: that's the default value for the parameter. Basically, the
advantage of the default parameter is that you need not to explicitly define
the non-parameterized constructor.

See the difference yourself with following 2 examples.

1)   *class A {
               int m;

               A (int a) {
                        m = a;
               }
     };*

when you declare an obj of the class A as :
          * A obj;*
in main(), then it reports an error. because the class lacks the constructor
of the form:
*          A() {
          }
*
2) *class A {
               int m;

               A (int a = 0) {
                        m = a;
               }
     };*

when you declare an obj of the class A as :
          * A obj;*
in main(), then it doesn't report error. because the default parameter lets
the user to skip the explicit(rather strictly) passing the argument value.
When user doesn't pass the argument value, it takes it as the default value
0.

On Wed, May 25, 2011 at 1:42 AM, Gaurav Saxena <[email protected]>wrote:

> Actually
>
>
> A(int *m=0*)
>> {
>> a=m;
>> }
>> not
>>   A*(int m*) {
>>                a = m;
>>                 }
>>
>
> means m has a default value of 0 ie this value will be used if no parameter
> is given . So when you pass it a parameter default value is simply ignored.
>
> On Wed, May 25, 2011 at 12:15 PM, Balaji S <[email protected]>wrote:
>
>> ya.. thanks :) it works. but.. we are initializing m to 0 in everycall
>> ryt.. ? then how does 1,2,3,....is initialized??
>>
>>  --
>> 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.
>>
>
>
>
> --
> Thanks and Regards ,
> Gaurav Saxena
>
>  --
> 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.
>



-- 
-Aakash Johari
(IIIT Allahabad)

-- 
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