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;
};