Given the following code:
Class User{
Task m_Task;
public function getTask("Do work") { return m_Task; }
}
Class Project{
Task m_Task;
public function getTask("Do work") { return m_Task; }
}
Class Task {
private m_Name;
public Task(name) { m_Name = name; }
}
Class Evil {
new Task = Error
}
In a language that does not support multiple inheritance, nested classes, or private classes, (private constructor not an option), how can you design a requirement that Task is only ever instantiated through User or Project? Ideally using only language constructs instead of code. Is there a design pattern?