Solved

CGPSArray illegal reference to data member

Posted on 2004-08-03
17
276 Views
Last Modified: 2013-11-20
class CGPSArray : public CStringArray

m_pGPSArray = new CGPSArray();
if (m_pGPSArray->AddGPSArray(sFileName, CAVIThread::lFrame1) > 1)
                        bIsGPSArray = TRUE;

error C2597: illegal reference to data member 'CAVIThread::lFrame1' in a static member function

Whats wrong with that?
0
Comment
Question by:Zmey2
  • 8
  • 4
  • 2
17 Comments
 
LVL 16

Accepted Solution

by:
nonubik earned 500 total points
ID: 11701330
Seems that you are inside a static method and lFrame1 is not a static member. Make it static. Or create an instance of the class and use a member-access operator.
0
 
LVL 5

Expert Comment

by:lwinkenb
ID: 11701378
Is lFrame1 a static variable?
If not, then that is your problem.  To access a non-static member variable, you must instantiate a class first.

In other words:
CAVIThread ct;
ct.lFrame1 = whatever;

If you want to use the member variable as in CAVIThread::lFrame1, then you need to make that variable static.

class CAVIThread
{
  static int lFrame1;
  //...
};
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11701445
do I hear an echo?
0
 
LVL 5

Expert Comment

by:lwinkenb
ID: 11701573
Your post was not there when I posted mine.  
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11701587
Then I must appologize.
0
 
LVL 4

Author Comment

by:Zmey2
ID: 11703159
got error C2512: CAVIThread ct;
LONG lFrame;

lFrame = ct.lFrame1;
if (m_pGPSArray->AddGPSArray(sFileName, lFrame) > 1)

error C2512: 'CAVIThread' : no appropriate default constructor available

I think thare is a problem connected with that fact, that i've got  lFrame1 in AVIViewer.cpp, and CAVIThread::lFrame1 in MainFrm.cpp...
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11703193
try declaring

static LONG lFrame;

in your AVIThread.h
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:nonubik
ID: 11703203
static LONG lFrame1;

in your CAVIThread class definition
0
 
LVL 4

Author Comment

by:Zmey2
ID: 11703766
Doesn't help :(


Linking...
AVIThread.obj : error LNK2001: unresolved external symbol "public: static long  CAVIThread::lFrame1" (?lFrame1@CAVIThread@@2JA)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static long  CAVIThread::lFrame1" (?lFrame1@CAVIThread@@2JA)
Debug/AVIViewer.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11703804
ok. you need to define it
in AVIThread.cpp, after include lines

LONG CAVIThread::lFrame1 = 0;

Put this line before any class method.
0
 
LVL 4

Author Comment

by:Zmey2
ID: 11712682
>ok. you need to define it
>in AVIThread.cpp, after include lines

>LONG CAVIThread::lFrame1 = 0;

>Put this line before any class method.

Can you expand on this, please?
0
 
LVL 4

Author Comment

by:Zmey2
ID: 11733172
Hi, nonubik!

Will you kindly be more specific on your last advice? Unfortunately, i can't give it a try - some things are not understood...
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11771876
I was on vacation...

A static member variable must be declared. See http://msdn.microsoft.com/library/en-us/vccelng/htm/class_27.asp for more info
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11771880
"A static member variable must be declared"
must be read
"A static member variable must be defined"  :)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 47
sumNumber challenge 16 98
ShiftLeft challenge 21 65
scoreUp challenge 14 48
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 discusses moving either the default database or any database to a new volume.

707 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

14 Experts available now in Live!

Get 1:1 Help Now