calling Parametrised construtor with less number of arguments

S

saxenavaibhav17

Actually at some place I am creating object of outcome class.

its taking five argument.

i don't want to give 3 and 4 th argument.

i want to give 1,2 and 5 th argument.

Outcome ot(0,MW_MESSAGE, , ,this);\



previously it was written like this

Outcome ot(0,MW_MESSAGE);

working fine



now situation come i need to give it a handle of parent window so i
need to pass this there.



base condtion is that I don't want to change the architure of
Constructor.

it should be as like as it was.











Outcome:utcome( int retVal, SeverityIndex sevIndex, UINT
uTitleStrID,DWORD dwHelpID, CWnd* pParentWnd/* = NULL*/)
{
m_retVal = retVal;
m_SevIndex = sevIndex;

m_uTitleStrID = uTitleStrID;

// test if it is a valid string id
if( m_uTitleStrID )
{
//MWResourceLoader resLoad;
CString strTitle;
BOOL bValid = strTitle.LoadString(m_uTitleStrID);
ASSERT(bValid);
}

// Set the Help ID
m_dwHelpID = dwHelpID;
m_bChangeMessageBoxButtonLabels = FALSE;
m_pParentWnd = pParentWnd;
}
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

Actually at some place I am creating object of outcome class.

its taking five argument.

i don't want to give 3 and 4 th argument.

i want to give 1,2 and 5 th argument.

You can either reorder the arguments in the constructor so that the
currently 5th parameter becomes the third, or you can can make a new
constructor taking only the three parameters you are interested in.
Outcome:Outcome( int retVal, SeverityIndex sevIndex, UINT
uTitleStrID,DWORD dwHelpID, CWnd* pParentWnd/* = NULL*/)

By the way, this is not the real constructor is it, because this one
can't be called with just two arguments.
 
S

saxenavaibhav17

You can either reorder the arguments in the constructor so that the
currently 5th parameter becomes the third, or you can can make a new
constructor taking only the three parameters you are interested in.


By the way, this is not the real constructor is it, because this one
can't be called with just two arguments.

hi erik u r rite absolutely but the problem is I can't change
defination of constructor due to some reason.
default value of these parmaeter is defined in the delaration of
construtor
thatswhy it was called previously when I pass only two value while
creating object
well Thanks a lot for ur help
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

hi erik u r rite absolutely but the problem is I can't change
defination of constructor due to some reason.
default value of these parmaeter is defined in the delaration of
construtor
thatswhy it was called previously when I pass only two value while
creating object

As I said, you can always create a new constructor.
 

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

Forum statistics

Threads
474,297
Messages
2,571,530
Members
48,252
Latest member
shilpadhussa

Latest Threads

Top