i wrote this code:
class A {
public:
A(){d=2.2;cout<<d;}
A(double d):d(d){cout<<d;}
double getD(){return d;}
private:
double d;
};
class Bing {
public:
Bing(){a=A(5.3);}
void f(){cout<<a.getD();}
private:
A a;
};
int main() {
Bing b;
b.f();
}
i get the output: 2.2 5.3 5.3 instead of 5.3 5.3. it's something in the constructor.... why am i getting this? how can i fix it?