I'm just learning php, but am an expert in C++ and others.
Can you tell me if forward declarations are allowed for classes?
E.g. if I'm representing a relationship between two classes, and they are allowed to know about each other. This is more appropriate when abstracting database tables as classes, where such relationships will exist.
Note, this example is contrived, I don't have any such class called source and target, and it probably doesn't compile. But it would be nice to have this association.
class Source
{
// constructors etc..removed
function FindTarget()
{
return new Target();
}
}
and a similar class target
class Target
{
// constructors etc.. removed
function FindSource()
{
return new Source();
}
}
I tried placing
class Target;
before the declaration of class Source, but the compiler spurted errors at me.
Is there a way of forward declaring a class or not?
Thanks in advance
Giles