Solved

Static members with VC++ 5.0

Posted on 1998-07-17
5
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 8

Expert Comment

by:trestan
ID: 1319389
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
ID: 1319390
Yup.  It's included and I'm still getting the error.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319391
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
ID: 1319392
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
ID: 1319393
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
substring method in java 1 142
sum13 challenge 24 149
Window placement 17 100
changeXy challenge 13 98
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

738 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