No, this is impossible neither in terms of language, nor in terms of classes.
In terms of classes: each instance of A contains an instance of B, which contains an instance of A, which ... => infinite recursion. This is not a problem with the version of the pointer, because the pointer may not point to a valid object, or all pointers of A may point to the same object, etc.
source share