Relative Content

Tag Archive for c++classconstructorinitialization

Calling contructor from another contructor leaves data members un-initialized

I was writing a function for reading temperatures at specific hours from a csv file and storing it inside Reading objects. I wanted to overload the constructor such that a Reading object could be initialized via direct arguments and a vector containing two arguments: hour and temperature. The reason I used a vector instead of something like a pair was because it was more convenient adding the hour and temperature to the vector when parsing each column in the csv file.