I'm having trouble understanding these few sentances from a book that i'm reading. The sentace referers to this code:
Code:
// englobj.cpp
// objects using English measurements
#include <iostream.h>
class Distance // English Distance class
{
private:
int feet;
float inches;
public:
void setdist(int ft, float in) // set distance to args
{ feet = ft; inches = in; }
void getdist() // get length from user
{
cout << "\nEnter feet: "; cin >> feet;
cout << "Enter inches: "; cin >> inches;
}
void showdist() // display distance
{ cout << feet << "\'-" << inches << '\"'; }
};
void main()
{
Distance dist1, dist2; // define two lengths
dist1.setdist(11, 6.25); // set dist1
dist2.getdist(); // get dist2 from user
// display lengths
cout << "\ndist1 = "; dist1.showdist();
cout << "\ndist2 = "; dist2.showdist();
}
"...However, we also want to define variables of type DISTANCE without initializing them, as we did in ENGLOBG.
Distance dist1, dist2;
In that program there was no constructor, but our definition worked just fine. How could they work without a constructor? Because an implicit constructor was built into the program automatically by the compiler and it created the objects, even thought we didn't define it in the class..."
Can someone explain what hes' talking about?