Well, I tried applying
1 2 3
|
AnyObject *pAny = NULL;
pAny = &(...);
pAny->show();
|
in different places of the code to see when Lex becomes AnyObject, and it seems I found the catch. If it doesn't help, I'll answer your questions in a greater detail.
(make_tree is a function creating a new binary tree out with two existing binary trees as branches and a given AnyObject as the root element; bt is a subsidiary btree variable; btree::root->d is the root value if it's still important. btree::root is a pointer to the root element (node* root), an element itself is defined as
1 2 3 4 5 6
|
struct node
{
AnyObject d;
node *ls;
node *rs;
};
|
)
OK. In the function make_tree there is a problematic assignment
rt->d=c;
rt is a *node element, so rt->d is an AnyObject, whereas c is a Lex object. After this,
1 2 3
|
AnyObject *pAny = NULL;
pAny = &(btree::root->d);
pAny->show();
|
produces the default string.
Is there any way I can redefine rt->d so it would still have AnyObject type, but could return the character contained in Lex when address with pAny->show()? As far as I understand, this assignment just doesn't work, but I don't know any alternative...
If you need more information about the meaning of any variables or procedures, the code is totally mine so I always can answer.