Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arguments in function

Status
Not open for further replies.

Arowana

Programmer
Feb 22, 2001
19
PT
Hi, I know this is a easy question but no one knows everythyng.

In my program i add a c++ file where i create a function.
In that function i want to pass two diferents arguments but one at a time in diferents ocasions.

ex.
CProcura dlg;//modal dialog box class

if(flag==1)

int x=Procura(dlg.m_name);
else
int x=Procura(dlg.m_number);

where m_name is a CString type and m_number is a int type.

The function was declared like: int Procura(void z);

Is that possible and correct?

Thank you in advance!
 
You have to declare a template for this function:

...
template <class T>
int Procura(T value)
{
// your code
}

When you call this function it will automatically substitute code for it.
Best Regards,

aphrodita@mail.krovatka.ru {uiuc rules}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top