Visability of class functions in open code subroutines.

M

mlieberman

I accidentally sent my query before it was done.

I have inherited a vison system written in C++ with microsoft MFC.

I want to use a class function RefreshDisplay() in other non-inheriting
classes and open code functions. RefreshDisplay() is defined as:

Device.h includes:
class CDevice
{
public:
...
int RefreshDisplay();
...
}

Device.cpp includes
int CDevice::RefreshDisplay(){...}

The header "Device.h" was included in both "otherClass.cpp" and in
"ourUtils.cpp"
and when called referred to as "CDevice::RefreshDisplay."

In both cases ver 6.0 Visual C++ 6.0 gives the same build/compile
message:

file.cpp(line) error C2352: 'CDevice::RefreshDisplay' : illegal call of
non-static member function
x:\devices\device.h(67) : see declaration of 'RefreshDisplay'

but I see nothing that is declared static, i.e.,
here is the relevant code:in the class CotherClass,
In OtherClass.h
class CotherClass
{
public:
...
bool PrepImage( (long& imgRaw, bool bFFC, bool bScale, bool bDif);
...
}

In otherClass.cpp
#include "otherClass.h"
#include "Device.h"
bool CSWPreProc::prepImage( .... nothing static ...) {... }

similarly in the open code function

In ourUtil.h
int ourUtil1(long imgIn, int bt, long& imgDeNoise);

In ourUtil.cpp
#include "ourUtil.h"
#include "device.h"
int ourUtil1(long imgIn, int bt, long& imgDeNoise)
{
...
CDevice::RefreshDisplay();
...
}

How can I get around this non recognition problem?
 
S

Steve McLellan

At the bottom of your sample:

int ourUtil1(long imgIn, int bt, long& imgDeNoise)
{
...
CDevice::RefreshDisplay();
...
}

That's a static call. Either you need access to an instance of a CDevice, or
RefreshDisplay needs to be declared static. It looks like you've altered the
filenames in the error mssage, so I acn't be sure, but this would definitely
account for the error.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top