P
pai
Hi ,
Below is the code .
**********************
#include<iostream>
using namespace std;
class A{
public:
int a;
A(){ cout << "Constructor" << endl; }
void Ab(){ //a=10; cout << "hello " << a << endl; }
};
int main(){
A *a;
a->Ab();
return 0;
}
--------------------
This answer when givin command ./a.out is as follows
hello 1474660693
how could the "print" method executed while I havnt created an object
and also the vaiable b is showing garbage value while varable have not
been allocatedmemory.
Can any one explain me how is this happeneing.
Thanks
Pai
Below is the code .
**********************
#include<iostream>
using namespace std;
class A{
public:
int a;
A(){ cout << "Constructor" << endl; }
void Ab(){ //a=10; cout << "hello " << a << endl; }
};
int main(){
A *a;
a->Ab();
return 0;
}
--------------------
This answer when givin command ./a.out is as follows
hello 1474660693
how could the "print" method executed while I havnt created an object
and also the vaiable b is showing garbage value while varable have not
been allocatedmemory.
Can any one explain me how is this happeneing.
Thanks
Pai