I am debugging some simulation software that has been written in C++, and am having trouble understanding part of the code.
The software simulates some entities moving in a 3D world, and their behaviour can be set such that they move in a straight line from A to B, spiral around a particular point, or follow a predefined route, etc.
As an entity moves in the simulation, some information about its movements is presented to the user- such as: its current speed, heading (direction), the distance to its current target, the time it will take to reach its current target & ETA at that location, etc.
The bug that I am currently working on is that the ETA and 'time to finish current leg' of a journey are displaying incorrect values to the user.
I have come across the following code in the C++ source file that is displaying this information to the user:
DateTimeAndZone fpETA(mCurrentTime);
SystemTimeTypes::addRelativeTimeToSystemTime(fpETA, flightPlanETA);
DateTimeAndZone
is a class, so fpETA
is an instance of that class... What I don't understand is how mCurrentTime
(which is also a DateTimeAndZone
), can be passed as a parameter of the instance of a class- in what appears to be the same way that a parameter is passed to a function.
If I go to the defintion of the DateTimeAndZone
class, there is a return
statement at the end of it that returns a static std::string_classname
.
Can anyone explain to me how a class can be passed as the parameter for the creation of a new class? What are the implications of this? Does it mean that the new class will take on the information stored in the existing class? Or is there something that I am missing here?
I came across this question on SO, but it doesn't really answer my question... Passing a class object as an argument in C++