R
Rahul
Hi Everyone,
I have the following program,
class A{
private:
int a;
public :
void func1();
};
void A::func1(){
cout <<"hello world";
}
int main(){
A *a1=NULL;
a1->func1();
return 0;
}
And it prints hello world. I think it is undefined behavior but i'm
assuming that the memory for the function is allocated as the compiler
parses through the class definition and hence there should be a way to
access the memory (function)... Is there any legal way without
creating an object of the class?
Thanks in advance ! ! !
I have the following program,
class A{
private:
int a;
public :
void func1();
};
void A::func1(){
cout <<"hello world";
}
int main(){
A *a1=NULL;
a1->func1();
return 0;
}
And it prints hello world. I think it is undefined behavior but i'm
assuming that the memory for the function is allocated as the compiler
parses through the class definition and hence there should be a way to
access the memory (function)... Is there any legal way without
creating an object of the class?
Thanks in advance ! ! !