Click here to Skip to main content
15,886,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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".
C++
#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;};
Posted

1 solution

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."
 
Share this answer
 
v2
Comments
Jeevan83 27-Mar-14 9:46am    
Thanks a lot! pwasse
[no name] 27-Mar-14 19:38pm    
No idea what you are trying to do but defining a structure within a class and then declaring an external reference to an instance of it from within the class is pretty bizarre. I would be thinking redesign or pointer or static in that order.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900