C++ program to add time object using the object as argument concept in OOP

Gowtham
Jul 12, 2021

--

The Below C++ program illustrates the use of objects as function arguments. It performs the addition of time in the hour and minutes format.

Since the member function sum() is invoked by the object T3, with the objects T1 and T2 as arguments, it can directly access the hours and minutes variables of T3, but the members of T1 and T2 can be accessed only by using dot operators like T1.hours and T1.minutes. Therefore inside the function sum() the variables hours and minutes refer to T3, T1.hours and T1.minutes refer to T1 and T2.hours and T2.minutes refer to T2.

--

--

Gowtham
Gowtham

No responses yet