Accessor functions


I was wondering if these accessor functions (or even the comments) are worth keeping. From value.h:

    //! Gets the loop option.
    bool get_loop()const { return loop_; }

    //! Sets the loop option.
    void set_loop(bool x) { loop_=x; }

    //! Gets the static option.
    bool get_static()const { return static_; }

    //! Sets the static option.
    void set_static(bool x) { static_=x; }

It seems unnecessary to me, but I usually program in C.


Those accessors are needed since those values are protected on the class. So to allow external classes not friend of ValueBase should use those accessors.


Ah, I see. Thanks!

Why are those variables protected when they could be public?

  • Charlie

because encapsulation, inheritance and information/data control…
what would happen if a data is set out of bounds ?
what would happen if path/string contain forbidden char ? … apsulation