Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CGPSArray illegal reference to data member

Posted on 2004-08-03
17
Medium Priority
?
300 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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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!

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

688 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