CGPSArray illegal reference to data member

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?
LVL 4
Zmey2Asked:
Who is Participating?
 
nonubikConnect With a Mentor Commented:
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
 
lwinkenbCommented:
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
 
nonubikCommented:
do I hear an echo?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
lwinkenbCommented:
Your post was not there when I posted mine.  
0
 
nonubikCommented:
Then I must appologize.
0
 
Zmey2Author Commented:
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
 
nonubikCommented:
try declaring

static LONG lFrame;

in your AVIThread.h
0
 
nonubikCommented:
static LONG lFrame1;

in your CAVIThread class definition
0
 
Zmey2Author Commented:
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
 
nonubikCommented:
ok. you need to define it
in AVIThread.cpp, after include lines

LONG CAVIThread::lFrame1 = 0;

Put this line before any class method.
0
 
Zmey2Author Commented:
>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
 
Zmey2Author Commented:
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
 
nonubikCommented:
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
 
nonubikCommented:
"A static member variable must be declared"
must be read
"A static member variable must be defined"  :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.