I have an issue when compiling my project in VC++. When I compile my project, it gives two errors, one is for the overload member and the other is for end-of-file
. Although I have used semicolon at the end of all classes, this error still appears. Here is the 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)
{
};
The error directs me to the definition of class 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;
};
The error happens at the line starts with : m_strName(strName)
. I have read other similar answers which addresses this issue, but they were too specific for those problems so I couldnt use it for my case. Can anybody please let me know how to fix this?
Parameters order in definition of your non-default constructor is different from one in the declaration. The right order is:
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)
{}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.