Solved

CGPSArray illegal reference to data member

Posted on 2004-08-03
17
287 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 54
List out all word 7 359
Fibonacci challenge 11 141
wordmultiple challenge 12 170
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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