Passing array argument to constructor

D

dev_15

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
 
S

Stuart Redmann

dev_15 said:
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
 
T

Tadeusz B. Kopec

dev_15 said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top