WORD &Key;
A link is always an alias for another object, and it must be initialized with an existing object. Therefore, the above declaration is not valid. Instead, the following is true:
WORD &Key = alreadyExistingKey;
[The above is no longer relevant, the question has changed.]
EDIT:
void somefunc1(Word &Key) { somefunc2(Key); } void somefunc2(char &char1) { return; }
[BCC32 error] Unit1.cpp (830): E2357 Link initialized with "unsigned short" requires lvalue type 'char'
The compiler tells you that somefunc2 expecting a [link, that is, an alias for] a char . But Key in somefunc1 is instead of Word , which I understand as typedef for unsigned short .
It seems to me that your "c-style" tool brutally reinterprets &Key , which is an unsigned short address, like a char address. So you go to somefunc2 , this is the first Key byte, interpreted as a (signed) char . I assume that the result depends on the essence. I would not rely on this code.
source share