构造函数不匹配的参数和参数 [英] constructor mismatch parameter and argument
本文介绍了构造函数不匹配的参数和参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怀疑CIAlert的构造函数具有多个参数,但是在执行构造函数时,仅传递了一个参数.怎么可能,任何人都可以解释下面的程序如何工作?
---------------------------------------- #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; } -------------------------------------------------
解决方案
那是因为所有其他输入参数都具有默认值.
看到这个:
http://www.learncpp.com/cpp-tutorial/85-constructors/ [ ^ ]
>
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; } -------------------------------------------------
解决方案
That''s because all of the other input parameters have default values.
See this:
http://www.learncpp.com/cpp-tutorial/85-constructors/[^]
这篇关于构造函数不匹配的参数和参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文