Compiler Grabs Wrong Overload

Posted on 2006-04-15
Last Modified: 2010-04-01
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

Question by:rickatseasoft
    LVL 11

    Assisted Solution

    Is there enough information in your calls of the functions for the compiler to recognize the passed parameters. Maybe it treats them just as pointers?
    LVL 14

    Assisted Solution

    If you explicitly cast your variables in your call, will it still go the wrong way?
    LVL 86

    Accepted Solution

    Can you post the code in question?

    >>but I can't find any way to view the name mangled output.

    Set the linker to generate a map file, you'll find the mangled name there.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    why "." vs "->" 23 110
    SetCurrentDirectory path limit 7 79
    java inner class, for the sole use of parameter passing 21 67
    Getting IP address 8 54
    Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
    This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now