In the following code I am giving an int value to class using type casting--
#include<iostream>
using namespace std;
class A
{
int a;
float b;
public:
A()
{
a=0;
b=0;
}
A(int m)
{
a=m;
cout<<"\n values are"<<a<<endl<<b;
}
};
void main()
{
A a1;
a1=1;
}
The members of this class are being initialised with zero but after assigning 1 to the object a1.. the value of b changes to a garbage value. Why does it do this way?