Connecting Tech Pros Worldwide Help | Site Map

illegal call to non-static member function

Newbie
 
Join Date: Sep 2006
Posts: 2
#1: Sep 7 '06
I am facig a problem..
this is the basic structure of my code.

#define @#problem() aaa::fn()

class aaa {
fn();
}

this is aaa.h

In xxx.cc

#include "aaa.h"
#include "xxx.h"

xxx::fn2() {

@#problem()

}

And xxx.h contains the instance of class aaa

when I try to compile it I get the error : illegal call to non static member function . See declaration of aaa::fn
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,162
#2: Sep 7 '06

re: illegal call to non-static member function


This is because you have tried to envoke aaa:fn() directly with instantiating an object of type aaa and the member function fn is not static so it can only be invoked through an instance of the class aaa.
Newbie
 
Join Date: Sep 2006
Posts: 2
#3: Sep 7 '06

re: illegal call to non-static member function


so class aaa {
fn();
} obj;

#define @#problem() obj.fn()

should that do???
Reply