Read-only archive of the All About Symbian forum (2001–2013) · About this archive

illegal use of non-static member

2 replies · 7,201 views · Started 22 April 2004

hi!
i am a totally newbie either with c++ and symbian programming, and i'm trying to develop a simple and minimal image viewer just to make a little practice.
i attached the program in the case my explanation will not be of much use.
i still have to develop the slideshow feature but i will do this later. now i have problem in listing bitmaps names to browse and select for viewing.
i used some of the engine code from the Graphics Tutorial on symbian.com in my AppUi.. but i've got problems (and also that's for displaying thumbnails, not file names but i'll change this later).. the compiler gives me a "illegal use of a non-static member" error. this error is about a ConstructL which i call in my AppUi.

Here's the code:

this is taken from the graphics tutorial

CListFiles* CListFiles::NewL()
{
CListFiles* self = new (ELeave) CListFiles();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop();
return self;
}

void CListFiles::ConstructL()
{
iLoadUtility = CMdaImageFileToBitmapUtility::NewL(*this);
iImageNames = new(ELeave) CArrayVarFlat<HBufC*>(1);
iBitmaps = new(ELeave) CArrayVarFlat<CFbsBitmap*>(1);
CollectFilesL();
}

and here's the error

void CProvaAppUi::ConstructL()
{
CQikAppUi::ConstructL();
CListFiles::ConstructL(); //here's the error
...

i would really pleased if you'd like to help me.. i really need to get a little skilled in order to make a future (hope i'll end it before july) simple project for my degree.
cheers,
TOOL

Attachments: Prova.zip (29 KB)

You are trying to call ContructL using a static call while construct was never declared static.

You should use something like CListFiles* listfiles = CListFiles::NewL(); or iListFiles = CListFiles::NewL();

Hi!,
Fistly Symbian uses a static function NewL to create the object.
In your class u have defined ConstructL as non-static so how can you call it without an object.You have to make your ConstructL static or you have to somehow pass the pointer of class defining constructL and call the function thru that pointer.

Note:Its bad a bad pratice to define ConstructL static only NewL are defined as Static .This is Symbian style of programming.SO best is give your function some other name.