Visual Studio로 프로젝트를 씁니다. 공용 멤버 함수를 WriteToPort
은 시리얼 포트를 통해 데이터를 보낼 수있다C++ 클래스 정적 멤버 함수 호출 오류
static UINT RecvDataFrame(LPVOID pParam)
및
class CSimApplianceDlg : public CDialog
{
// Construction
public:
CSimApplianceDlg(CWnd* pParent = NULL); // standard constructor
// Implementation
protected:
HICON m_hIcon;
// Added for Serial Port operation
static UINT RecvDataFrame(LPVOID pParam); // Process received data
......
private:
......
unsigned char m_SendData[MAX_LEN]; // Data to be sent
int len; // the length of data to be sent
public:
CSerialPort m_Port; // CSerialPort Object
......
CSerialPort
CSerialPort m_Port
: 프로젝트에서 나는 두 멤버가 CSimApplianceDlg라는 클래스를 구축 할 수 있습니다.
public:
void WriteToPort(char* string);
void WriteToPort(char* string,int n);
void WriteToPort(LPCTSTR string);
void WriteToPort(LPCTSTR string,int n);
나는 UINT CSimApplianceDlg :: RecvDataFrame (LPVOID pParam)에
m_Port.WriteToPort(m_SendData,len);
1> E : \ mysourcecode \ smarthome \ simappliance \ simappliance \ simappliancedlg.cpp (557) : 오류 C2228은 '왼쪽 CSimApplianceDlg :: m_SendData '
.WriteToPort는'\ mysourcecode \ smarthome \ simappliance \ simappliance \ simappliancedlg.cpp (557) : 오류 C2597 비 정적 멤버 불법 참조 클래스/구조체/노동 조합
1> 전자 있어야합니다 ' 1> e : \ mysourcecode \ smarthome \ simappliance \ simappliance \ simappliancedlg.cpp (557) : C2597 오류 : 비 정적 멤버 'CSimApplianceDlg :: len'에 대한 잘못된 참조
어떻게 이러한 오류를 처리 할 수 있습니까? 그리고 내가 LPCTSTR
에 익숙하지 않기 때문에 어느 WriteToPort
이 호출됩니다.
오류가 발생한 코드를 표시하는 것을 잊었습니다. –
아마도'CSerialPort' 클래스의 * 인스턴스 * 생성에 실패했습니다. Michael이 말했듯이, 실제 코드를 볼 수 없다면 확실하게 말할 수 없습니다. 질문을 [mcve]로 업데이트하십시오. –
"m_Port.WriteToPort (m_SendData, len);"호출시 오류가 발생했습니다. – pellyhawk