Hi I have two header files TimeRepresentation.h and GlobalTime.h, which has a TimeRepresentation variable declared in the private section of GlobalTime.h. I was wondering if it was possible to set the internals of the TimeRepresnetation localTime in a test driver by doing something like globaltime.get_localTime().set_seconds(15);?
or any other way to set a subclasses internals would help. Thank You
UInteger32 is typedef int
i've already tested that it complies with the driver, just need a way to set the internals of a subclass
get_localTime() returns localTime and set_seconds(15) sets the variable seconds in TimeRepresentation to 15 using seconds = x, where x is 15
I wanted to see if it was possible to see if one could set the internals of a subclass within the class, without making extra mutators for the class. Say I have, an accessor to the subclass that just returns the subclass, can i use the subclasses mutator to edit. Something like class.get_subclass().set_variable_in_subclass(15), where class is a declaration of Class, get_subclass() is the classes mutator that returns the subclass, and set_variable_in_subclass(15) is the subclasses mutator to edit the contents of the subclass. I tried this, it compiled but didn't set anything so I was looking for suggestions in doing this without, creating new mutators in the class or using a temporary variable.
sorry for the confusion, but im not very good at explaining.
I may have the wrong terminology but on line 79, TimeRepresentation is another class that I have defined, and have shown the header file at the top. TimeRepresenatation is a class that is used in another class called GlobalTime. I was writing a driver for GlobalTime and wanted to know how to set the internals of the TimeRepresentation class within the GlobalTime class. Below is my GlobalTime.cc file, I think I may need to pass by reference or value to do this correctly, but not quite sure how I would do it.
You should call the member functions you took the time to create. If you intended on ditching encapsulation and just setting values directly, why would you have written the functions?