class SearchElement
{
public:
int m_step_id;
int m_track_id;
float m_energy;
SearchElement()
{
int m_step_id = 0;
int m_track_id = 0;
float m_energy = 0;
}
};
Where I have defined a default constructor to initialize the variables. When I call on one of these class members in my main program these members are not initialized to 0. For example,
1 2 3 4 5 6
void main()
{
SearchElement ele;
int energy = ele.m_energy;
cout << energy << endl;
}
yields a garbage value. Why does this not yield 0?