Passing array argument to constructor

Discussion in 'C++' started by dev_15, Nov 27, 2007.

  1. dev_15

    dev_15 Guest

    Hi, I have a problem with the following code, which doesn't compile on
    the MSVC8 compiler.

    CReportScreen derives from CDialog // although this probably has
    nothing to do with it
    HBITMAP is a typedef for an int

    CReportScreen(CWnd* pParent = NULL, HBITMAP bmpArray[3]);

    CReportScreen::CReportScreen(CWnd* pParent , HBITMAP bmpArray[3])
    : CDialog(CReportScreen::IDD, pParent),

    {
    }

    then i instantiate the CReportScreen as follows :

    CReportScreen reportDlg(NULL, m_hLogoBmpArray);

    where m_hLogoBmpArray is declared as HBITMAP m_hLogoBmpArray [3]


    I'm getting the following compile error

    error C2548: 'CReportScreen::CReportScreen' : missing default
    parameter for parameter 2
    in the header file declaration
    CReportScreen(CWnd* pParent = NULL, HBITMAP bmpArray[3]);


    Thanks
    dev_15, Nov 27, 2007
    #1
    1. Advertising

  2. dev_15 wrote:
    > Hi, I have a problem with the following code, which doesn't compile on
    > the MSVC8 compiler.
    >
    > CReportScreen derives from CDialog // although this probably has
    > nothing to do with it
    > HBITMAP is a typedef for an int
    >
    > CReportScreen(CWnd* pParent = NULL, HBITMAP bmpArray[3]);


    This declaration is not valid: All parameter declarations that follow a
    parameter with a default value must have a default value, too. In your case you
    would have to either A) remove the default parameter from parameter pParent or
    B) add a default parameter to bmpArray. Option B cannot be used as the bitmap
    array is certainly essential to the construction of CReportScreen objects.

    I posted the rest of the answer to microsoft.public.vc.mfc, as this would be OT
    here.

    Regards,
    Stuart
    Stuart Redmann, Nov 27, 2007
    #2
    1. Advertising

  3. On Tue, 27 Nov 2007 13:33:24 +0100, Stuart Redmann wrote:

    > dev_15 wrote:
    >> Hi, I have a problem with the following code, which doesn't compile on
    >> the MSVC8 compiler.
    >>
    >> CReportScreen derives from CDialog // although this probably has
    >> nothing to do with it
    >> HBITMAP is a typedef for an int
    >>
    >> CReportScreen(CWnd* pParent = NULL, HBITMAP bmpArray[3]);

    >
    > This declaration is not valid: All parameter declarations that follow a
    > parameter with a default value must have a default value, too. In your
    > case you would have to either A) remove the default parameter from
    > parameter pParent or B) add a default parameter to bmpArray. Option B
    > cannot be used as the bitmap array is certainly essential to the
    > construction of CReportScreen objects.


    There is also option C) - change parameters order.

    --
    Tadeusz B. Kopec ()
    The use of anthropomorphic terminology when dealing with computing systems
    is a symptom of professional immaturity.
    -- Edsger Dijkstra
    Tadeusz B. Kopec, Nov 27, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Generic Usenet Account
    Replies:
    10
    Views:
    2,197
  2. Trans
    Replies:
    3
    Views:
    181
    Robert Klemme
    Jan 26, 2005
  3. ±è ÁØ¿µ
    Replies:
    7
    Views:
    237
    Einar Magnús Boson
    Nov 27, 2008
  4. ingoweiss
    Replies:
    4
    Views:
    200
    Julian Turner
    May 12, 2006
  5. User1014
    Replies:
    1
    Views:
    174
    Richard Cornford
    Nov 30, 2006
Loading...

Share This Page