Honestly, I really don't know how to ask this question, so please don't be angry :)
In any case, I want the mutators (setters) in my class to return thisto allow jQuery-like a.name("something").address("somethingelse");
. I have a parent class ( Entity) and several child classes ( Client, Agent etc.). Mutators for most things are inherited from a class Entity(for example, a name or address), but they return an object Entity, so I cannot call client mutators on them.
In other words:
Entity& Entity::name( const string& name ) {
_name = name;
return *this;
}
Client& Client::budgetRange( const long int& range ) {
_budgetRange = range;
return *this;
}
then when I call him:
Client a; a.name("Dorota Adamczyk").budgetRange(50);
The compiler (logically) says that the Entity object does not have a budgetRange member (since the name returns Entity, not the client).
: - ? Entity , :)
: D