3
Well, I had asked but I guess it wasn’t clear so I’ll edit as you suggested, basically I wanted to do an application in Delphi using a Tsala class and several Tpessoa classes, however, the Tpessoa class needs to refer to Tsala in order to take information from her and modify it when necessary, and the classroom class needs a reference to the Tpessoa class in order to create a list of people in the room and be able to modify these people.
For example: Do something like this somewhere in the Tpessoa class:
self.sala.pegarPessoaPorNome("Alberto").Dar("Refrigerante");
Already in the Tsala class would have something like this:
function pegarPessoaPorNome(nome: string): TPessoa;
begin
for pessoa in self.pessoas do
if pessoa.nome = nome then Exit(pessoa);
end;
However, here comes the problem, since these two classes are in separate Units, it would give an error in the "circular reference" compiler because I am using the Tsala class in the Tpessoa class and the Tpessoa class in the Tsala class.. How could I fix this without having to appeal to Opointer or Tobject?
I don’t know if I understand clearly what you need. But your problem can be solved with Objectlist<T>. What happens is that with Objectlist your Tpessoa class will belong to Tsala, that is, Cvoce will have a Listasala.ListaPessoa. If you agree with the idea, I can put together a prototype of what it would look like.
– Victor Tadashi
Victor Tadashi, I didn’t understand was anything in this question, if that’s what you understood until you go, but if that’s not it there, I have to study more!
– Junior Moreira
Daniel Yohan, explains why you need it there, at least an explanation of the use, if not your question will be closed, if it is not possible to replicate the error/problem, so this does not exist. Explain the need, maybe we can help you some other way!
– Junior Moreira