Compiler Grabs Wrong Overload
Posted on 2006-04-15
I have a class that contains two different versions of the same function called GetZip(). In one version, it uses CStrings that are themselves pointed to controls, in the other, it uses the controls themselves.
The two are declared thus:
int GetZip(CDialog *pParent,struct dbffile *amaf08z,CString *pCity, CString *pState, CString *zip);
int GetZip(CDialog *pParent,struct dbffile *amaf08z, CCapEdit *pCtrlCity, CStateCombo *pCtrlState, COXMaskedEdit *pCtrlZip);
where CCapedit is a control derived from CEdit, CStateCombo is derived from CComboBox, and COXMaskedEdit is a third party Masked Editor derived from CEdit.
The call that accesses the controls directly is used throughout the program in various dialogs, and works, as advertised, except in one case where the compiler insists on latching onto the one that uses CStrings.
Since I have both versions to work with, it is easy enough to rewrite the call to use the variables rather than the controls, but what is going on here? I am very concerned that I have some issues that need to be dealt with now in the proper fashion, rather than just designing a work-around.
1. I thought about an errant header file, and there is only one header on the system where GetZip in mentioned.
2. I thought that perhaps name mangling is the culprit (A CString looks like a Control to the name mangler), but I can't find any way to view the name mangled output. Something like -P or -E in a traditional 'c' compiler. If this is the case, why would it work elsewhere in the same program, albiet a different source file?
3. In this source file, the (I think they are called tooltips) window that comes up after the first '(' knows that both instances are available. As a matter of fact, the overload that uses controls is the first one mentioned.
Any help that you can offer will be greatly appreciated.
Thanks in advance, Rick