toString and opEquals
Let’s learn about toString and opEquals functions for classes.
toString
Same with structs, toString
enables using class objects as strings. The following code shows how toString()
is implicitly called when displaying class objects:
Get hands-on with 1400+ tech skills courses.