Assigning a function to a variable in C++

What happens if you assign a function to a variable as shown below

unsigned char uchHeaderVer; 
uchHeaderVer = GetCodec(Page.Version);

BYTE CWAV::GetCodec(BYTE byVersion)
{
    RecorderInfoMap::iterator it;

    if ((it = m_mapRecInfo.find(byVersion)) != m_mapRecInfo.end()) {
        return (BYTE) ((*it).second.nCodec);
    } else {
        return 4;
    }
}

Version is of type BYTE and is stored in a typedef struct

Answer

What happens if you assign a function to a variable as shown below

You aren’t assigning a function to a variable. You are calling a function, and assigning the result to that variable.

You haven’t shown what BYTE is, but it is very likely to be a type alias for either unsigned char (or possibly char).

You can’t assign a function to a variable, because functions aren’t objects. You can only assign pointers to functions to variables, e.g.

BYTE (*pGetCodec)(BYTE) = &CWAV::GetCodec;
auto pGetCodec2 = &CWAV::GetCodec;
using GetCodecF = BYTE (*)(BYTE);
GetCodecF pGetCodec3 = &CWAV::GetCodec;