c++ default value in function call

Discussion in 'C++' started by saravanan_, Feb 11, 2008.

  1. saravanan_

    saravanan_ New Member

    Joined:
    Oct 24, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    hi ,
    I am new to this forum. Any one pls. give me a solution for my problem.
    i have a c++ function
    void func(int a=10,int b=20)
    {
    ..........
    }

    i need to call the function with only one argument depends on certain condition.
    some time i need call with two arguments.
    I tired with two arguments and with one in first argument say
    func(12);
    the above one is working but, i want to call the function with
    func(,59);
    pls give me a solution for the above one.

    Thanks in advance..
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,336
    Likes Received:
    377
    Trophy Points:
    83
    You need to pass a value for the first argument always. It cannot be that you don't provide an argument for the first in the list. You can use 0 of course.
     
  3. saravanan_

    saravanan_ New Member

    Joined:
    Oct 24, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    First of all Thanks .....shabbir for your reply...
    So i have to pass the 1st and 2nd argument also...
    Actually in PL/SQL it is possible to pass the 2nd args only, that why i asked this question.
    Once again thanks for the reply..
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice