S
santosh
class MyClass
{
private:
static int a;
float b;
char c;
public:
MyClass():b(0),c('\0'){};
static int DoMore(int p_a)
{
a=a+p_a;
cout<<"a="<<a<<endl;
return a;
}
float Increment(float p_f)
{
b+=p_f;
cout<<"b="<<b<<endl;
return b;
}
};
int main(void)
{
int (MyClass::*fn_ptr1)(int);
fn_ptr1=&MyClass:oMore;
fn_ptr1(5);
return 0;
}
Here I am getting Compilation error.
If I write like this bellow, It is OK(working)
int main(void)
{
int (*fn_ptr1)(int);
fn_ptr1=&MyClass:oMore;
fn_ptr1(5);
return 0;
}
Why it is so?
{
private:
static int a;
float b;
char c;
public:
MyClass():b(0),c('\0'){};
static int DoMore(int p_a)
{
a=a+p_a;
cout<<"a="<<a<<endl;
return a;
}
float Increment(float p_f)
{
b+=p_f;
cout<<"b="<<b<<endl;
return b;
}
};
int main(void)
{
int (MyClass::*fn_ptr1)(int);
fn_ptr1=&MyClass:oMore;
fn_ptr1(5);
return 0;
}
Here I am getting Compilation error.
If I write like this bellow, It is OK(working)
int main(void)
{
int (*fn_ptr1)(int);
fn_ptr1=&MyClass:oMore;
fn_ptr1(5);
return 0;
}
Why it is so?