0

Suppose the following DTO class. Which of the two getters breaks encapsulation least?

class Foo
    {
    public:
        /*Return the most primitive type. Caller do not need
        to worry about what Array is*/
        const RecType* dataBeginGet() const;
        const RecType* dataEndGet() const;

        /*Return a reference to the Array.
         Caller do not need to call two methods before iteration
        */
        const Array<RecType>& dataGet() const
            {return m_data;}

    private:
        Array<RecType> m_data;
    };
gnat
  • 20,543
  • 29
  • 115
  • 306
user877329
  • 501
  • 3
  • 14

0 Answers0