We help IT Professionals succeed at work.

Static members with VC++ 5.0

awong726
awong726 asked
on
Medium Priority
284 Views
Last Modified: 2013-11-20
I'm using VC++ 5.0 and I have static members in a class that I wrote.
I'm trying to assign values to them from the outside, but I get an error that looks like this:

ipserialDlg.obj : error LNK2001: unresolved external symbol "public: static int  CMyDataSocket::m_ReadState" (?m_ReadState@CMyDataSocket@@2HA)
MyDataSocket.obj : error LNK2001: unresolved external symbol "public: static int  CMyDataSocket::m_ReadState" (?m_ReadState@CMyDataSocket@@2HA)

m_ReadState is the member, and it was declared like this:
static BOOL m_ReadState;

ipserialDlg is the program that's trying to set the variables, with code that looks like this:
CMyDataSocket::mReadState=TRUE;

Any ideas?  I am using bad syntax?
Comment
Watch Question

Commented:
The LNK2001 error is usually occurred when the file containing the sympol is not included in the file using the symbol. Check to see whether you include the file containing the class CMyDataSocket.

Author

Commented:
Yup.  It's included and I'm still getting the error.

Commented:
The LNK2001 error is usually occurred when the file containing the sympol is not included in the file using the symbol. Check to see whether you include the file containing the class CMyDataSocket.

Commented:
I think use extern m_ReadState; BOOL m_ReadState=TRUE; at the begining of your file can correct this error.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.