找不到超载成员

时间:2017-04-22 04:43:29

标签: c++ visual-c++ error-handling compiler-errors

在VC ++中编译项目时遇到问题。编译项目时,它会产生两个错误,一个是重载成员,另一个是end-of-file。虽然我在所有类的末尾都使用了分号,但仍会出现此错误。 这是CGCustomert.cpp

    #include "stdafx.h"
#include "GCustomert.h"
#include<string>
using namespace std;

CGCustomert::CGCustomert(void)
{
    m_strName = _T("Unknown");
    m_bMale = TRUE;
    m_strPhoneNo = _T("88888888888");
    m_strQQNo = _T("00000");
    m_strNumber =_T("");
    m_strDate =_T("");
    m_strCompanyName = _T("");
    m_strAddress = _T("");
    m_iAge = 0;
    m_strState = _T("");
    m_strLimit = _T("");
    m_strRemarks =_T("");
}; 
CGCustomert::CGCustomert(CString strName, BOOL bMale, CString strPhoneNo, CString strQQNo, int iAge,CString strNumber,
    CString strDate,CString strCompanyName,CString strAddress,CString strState,CString strLimit,CString strRemarks )
: m_strName(strName), m_bMale(bMale), m_strPhoneNo(strPhoneNo), m_strQQNo(strQQNo), m_strNumber ( strNumber),m_strDate ( strDate),
    m_strCompanyName ( strCompanyName),m_strAddress ( strAddress),m_iAge ( iAge), m_strState ( strState),m_strLimit (strLimit),
    m_strRemarks ( strRemarks)
{

};  //end of CPerson::CPerson()

CGCustomert::~CGCustomert(void)
{
};

错误将我引导到类CGCustomert的定义:

    #pragma once
class CGCustomert
{
public:
    CGCustomert(void);
    CGCustomert(CString strName, BOOL bMale = TRUE, CString strPhoneNo = _T("88888888888"),
CString strQQNo = _T("0000"), CString strNumber =_T(""),CString strDate =_T(""),
CString strCompanyName = _T(""),CString strAddress = _T(""),int iAge = 0,CString  strState = _T(""),CString
strLimit = _T(""),CString strRemarks =_T(""));
    ~CGCustomert(void);

public:
    CString     GetName()                       { return m_strName; }
    BOOL            IsMale()                            { return m_bMale; }
    CString     GetPhoneNo()                        { return m_strPhoneNo; }
    CString     GetQQNo()                       { return m_strQQNo; }
    CString     GetNumber()                     { return m_strNumber; }
    CString    GetDate()                       {return   m_strDate; }
    CString    GetCompanyName()                 {return  m_strCompanyName;}
    CString    GetAddress()                       {return  m_strAddress;}
    int         GetAge()                         {return  m_iAge; }
    CString    GetState()                             {return  m_strState;}
    CString     GetLimit()                               {return  m_strLimit;}
    CString    GetRemarks()                                  {return m_strRemarks; }

    void        SetName(CString strName)            { m_strName = strName; }
    void        SetMale(BOOL bMale)             { m_bMale = bMale; }
    void        SetPhoneNo(CString strPhoneNo)  { m_strPhoneNo = strPhoneNo; }
    void        SetQQNo(CString strQQNo)            { m_strQQNo = strQQNo; }
    void        SetNumber(CString strNumber)            { m_strNumber = strNumber; }
    void        SetDate(CString strDate)              { m_strDate = strDate; }
    void        SetCompanyName(CString strCompanyName)   { m_strCompanyName = strCompanyName;}
    void        SetAddress(CString strAddress)         {m_strAddress = strAddress;}
    void        SetAge(int iAge)                       { m_iAge = iAge;}
    void        SetState(CString strState)             { m_strState = strState;}
    void        SetLimit(CString strLimit)             { m_strLimit = strLimit;}
    void        SetRemarks(CString strRemarks )        {m_strRemarks = strRemarks;}






public:
    CString     m_strName;          
    BOOL        m_bMale;            
    CString     m_strPhoneNo;       
    CString     m_strQQNo;          
    CString    m_strNumber;        
    CString    m_strDate;          
    CString    m_strCompanyName;    
    CString   m_strAddress;       
    int     m_iAge;             
    CString   m_strState;       
    CString   m_strLimit;       
    CString  m_strRemarks;       
};

错误发生在以: m_strName(strName)开头的行。 我已经阅读了其他类似的答案来解决这个问题,但它们对于那些问题太具体了,所以我不能用它来解决这个问题。有人可以告诉我如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

非默认构造函数定义中的参数顺序与声明中的不同。正确的顺序是:

CGCustomert::CGCustomert(CString strName, BOOL bMale, CString strPhoneNo,
    CString strQQNo, CString strNumber, CString strDate,
    CString strCompanyName, CString strAddress, int iAge, CString  strState, CString
    strLimit, CString strRemarks) :
    m_strName(strName), m_bMale(bMale), m_strPhoneNo(strPhoneNo), m_strQQNo(strQQNo), m_strNumber(strNumber), m_strDate(strDate),
    m_strCompanyName(strCompanyName), m_strAddress(strAddress), m_iAge(iAge), m_strState(strState), m_strLimit(strLimit),
    m_strRemarks(strRemarks) 
{}