Hi everyone, I am studing on classes and I found an example that I cannot figure out how it works
Code:
class Distance{
private:
int feet;
int inch;
public:
Distance (); //Constructor
void getDist ();
void showDist ();
Distance addDist( Distance d2 );
Distance subDist( Distance d2 );
};
and this is the definition
Code:
Distance Distance:: addDist( Distance d2 )
{
Distance temp;
temp.feet = feet + d2.feet;
temp.inch = inch + d2.inch;
if( temp.inch >= 12)
{
temp.feet++;
temp.inch -= 12;
}
return temp;
}
I cannot understand this line inside the class: Distance addDist( Distance d2 );
It creates an object "addDist" passing as parameter an other object "d2"?
Also I don't understand the syntax of this line: Distance Distance:: addDist( Distance d2 )
Thanks in advance