Solved

Static members with VC++ 5.0

Posted on 1998-07-17
5
267 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?
0
Comment
Question by:awong726
  • 3
5 Comments
 
LVL 8

Expert Comment

by:trestan
Comment Utility
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.
0
 

Author Comment

by:awong726
Comment Utility
Yup.  It's included and I'm still getting the error.
0
 
LVL 8

Expert Comment

by:trestan
Comment Utility
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.
0
 
LVL 8

Expert Comment

by:trestan
Comment Utility
I think use extern m_ReadState; BOOL m_ReadState=TRUE; at the begining of your file can correct this error.
0
 

Accepted Solution

by:
zingo earned 20 total points
Comment Utility
Have you initialized your static variable? If not, write a statement like this:

BOOL CMyDataSocket::m_ReadState = TRUE;

at the beginning of the MyDataSocket.cpp file.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 76
ODBC Connection Logging, ADO.NET 6 49
Macro to save highlighted rows as a separate file 5 38
NotAlone Challenge 20 70
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now