Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have a doubt that CIAlert has constructor with more than one parameters, but while executing the constructor only one argument is passed. How is it possible , Can any one explain how the below program works?
----------------------------------------
#ifdef _ASGDLL
#define ASGDLL_EXP __declspec(dllexport)
#else
#define ASGDLL_EXP __declspec(dllimport)
#endif

class ASGDLL_EXP CIAlert
{

// Constructors
public:
    CIAlert(WORD wCategoryParam, LPCTSTR lpszSourceName = PROJECT_ERROR_SOURCE,  LPCTSTR lpszMsgsModuleName = PROJECT_ERROR_MSG_SOURCE);

// Destructors
public:
    virtual ~CIAlert();

}


-----------------------------------------------------

#define C_STOREUPD_MAIN                  ((DWORD)0x000000FAL)

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    CIAlert alert(C_STOREUPD_MAIN);
    int nRetCode = 0;
}

-------------------------------------------------
Posted
Updated 19-Jul-12 5:15am
v2

1 solution

That's because all of the other input parameters have default values.

See this:
http://www.learncpp.com/cpp-tutorial/85-constructors/[^]
 
Share this answer
 
Comments
Member 4409296 19-Jul-12 11:30am    
what constructor will execute using argument "C_STOREUPD_MAIN"
CIAlert alert(C_STOREUPD_MAIN);
Member 4409296 19-Jul-12 11:30am    
Member 4409296 - 7 secs ago
what constructor will execute using argument "C_STOREUPD_MAIN"
CIAlert alert(C_STOREUPD_MAIN);
[no name] 19-Jul-12 13:19pm    
There is only one constructor in that code so which constructor do you think is going to execute?
Albert Holguin 19-Jul-12 14:40pm    
Like Wes said, there's only one... so only that one will execute... the other parameters that you didn't specify just use their default values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900