S
shaun roe
Hello,
I am working in a framework with certain restrictions; in particular I
have a 'data' class with getter and setter methods, and a some 'filling'
classes which know how to insert the data to the data class (they match
various sources such as a text file or a database, and then fill the
data).
The filling methods use the 'setter' methods of the data class, but then
I want to present the data class to the outside world (i.e. other
classes in the program) such that the setter methods cannot be used by
anyone else.
The sledgehammer approach would be to declare the 'setter' methods
private or protected and declare each of the fillers as a friend.
However, I am free to introduce some inheritance structures... if I make
a base class for the fillers and declare *it* to be a friend, will the
derived classes also be friends?
Is this reasonable?
I am working in a framework with certain restrictions; in particular I
have a 'data' class with getter and setter methods, and a some 'filling'
classes which know how to insert the data to the data class (they match
various sources such as a text file or a database, and then fill the
data).
The filling methods use the 'setter' methods of the data class, but then
I want to present the data class to the outside world (i.e. other
classes in the program) such that the setter methods cannot be used by
anyone else.
The sledgehammer approach would be to declare the 'setter' methods
private or protected and declare each of the fillers as a friend.
However, I am free to introduce some inheritance structures... if I make
a base class for the fillers and declare *it* to be a friend, will the
derived classes also be friends?
Is this reasonable?