类成员的存储类无效 [英] Invalid storage class for a class member

查看:865
本文介绍了类成员的存储类无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在头文件中定义一个结构,以便我可以在多个.cpp文件中使用它。而且我想在不同的.cpp文件中使用相同的结构变量。我试过并得到了这个错误。请帮我。这是我的整个头文件,结构的定义在底部。谢谢!我的错误是类成员的存储类无效。

I wanna define a structure in a header file so that I can use it in multiple .cpp files. And also I wanna use the same structure variable in different .cpp files. I tried and got this error. Please help me. This is my entire header file, the definition of structure is at the bottom. Thanks! And my error is "invalid storage class for a class member".

#pragma once
#include "mysocket1.h"
#include "mysocket2.h"
#include "FineDfThresholdLB.h"


// CsocketDlg dialog
class CsocketDlg : public CDialogEx
{
// Construction
public:
	CsocketDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_SOCKET_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CButton m_ctlConnect;
	CString m_strMessage;
	CString m_strName;
	int m_iPort;
	CListBox m_ctlRecvd;
	CListBox m_ctlSent;
	int m_iType;
	afx_msg void OnRType();
	afx_msg void OnServer();

public:
	afx_msg void OnClickedBconnect();
	
	void OnAccept(void);
	void OnConnect(void);
	void OnSend(void);
	void OnReceive(void);
	void OnClose(void);
private:
	
	mysocket2 m_sConnectSocket;
	mysocket2 m_sListenSocket;
public:
	afx_msg void OnClickedBsend();
	afx_msg void OnClickedBclose();
private:
	CFineDfThresholdLB m_dFineDfThresholdLB;
public:
	afx_msg void OnClickedFinedfthresholdlbbutton();
protected:
	struct setthresholdfinedflb{
		unsigned char sof_lb;
		//unsigned char msg_type;
		unsigned short command_code;
		unsigned short sequence_no;
		unsigned int msg_length;
		unsigned char eof_lb;
		unsigned char threshold_value;
	};
extern struct setthresholdfinedflb set_thresholdfinedflb;};

推荐答案

通过阅读错误看似显而易见。



http://publib.boulder.ibm.com/infocenter/comphelp/v7v91 /index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc03extsc.htm [ ^ ]



•在C ++中,extern声明不能出现在类范围内。
Seems obvious by reading the error.

http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc03extsc.htm[^]

"•In C++, an extern declaration cannot appear in class scope."


这篇关于类成员的存储类无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆