wts diff b/w int i=100 , i=100 in constructor?
While executing below programs i getting different results
Code:
#include<iostream>
using namespace std;
class c
{
public :
int i;
c();
};
c::c()
{
int i=20;
}
int main()
{
c c1;
cout<<c1.i<<"\n";
return 0;
}
putput:1200034523
Code:
#include<iostream>
using namespace std;
class c
{
public :
int i;
c();
};
c::c()
{
i=20;
}
int main()
{
c c1;
cout<<c1.i<<"\n";
return 0;
}
output : 20
anybody let me know the why if i place int in constructor it reflecting on result?
i look for your further replys