Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have seen a VC++ code.

::FindNextFile().It is an MFC function.Can we call this function without using "::"

operator.If then why we are using :: operator.Also i have seen same calling

procedure in an user defined function.And it is

C++
::DisplayMessage(&m_RichEditLog,csMessage,1);

And the corresponding .CPP file is

C++
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
DWORD CALLBACK RichEditStreamInCallBack(DWORD dwCookie,LPBYTE pbBuff,LONG cb, LONG *pcb)
{
	return 0;
}
void DisplayMessage(CRichEditCtrl * pRichEdit,const CString &cstrMessage,int nFlags/*=FALSE*/)
{

	
	
}

void SaveText(CRichEditCtrl * pRichEdit,const CString & strFile)
{
	
}

DWORD CALLBACK RichEditStreamOutCallBack(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{

	return 0;
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

.h file is
C++
------------------------------------------------------------------------------------------------------------------------------------------------------------------------

DWORD CALLBACK RichEditStreamInCallBack(DWORD dwCookie,LPBYTE pbBuff,LONG cb, LONG *pcb);

void DisplayMessage(CRichEditCtrl * pRichEdit,const CString & cstrMessage,int nFlags/*=FALSE*/);

void SaveText(CRichEditCtrl * pRichEdit,const CString & strFile);
static DWORD CALLBACK RichEditStreamOutCallBack(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Please help me.

Thanks in advance
Posted
Updated 14-Dec-11 18:50pm
v2

1 solution

This is used in situations where you have function in your class with its name same as one in win32 API(global function) function name. for example, within the Visual studio file "AFXWIN.h", we have a function called AfxMessageBox(). suppose you have a class CMyClass. It also has a function called AfxMessageBox(). your class header includes the file "AFXWIN.h".

C++
#include <afxwin.h>
....
....
class MyClass
{
....
int AfxMessageBox(...)
{
 //DO SOMETHING
}
....
}
.........</afxwin.h>


When you call the function AfxMessageBox() from your class, it will point to the member function AfxMessageBox() in your class. But what if you want to call the MFC function AfxMessageBox()??.
That time you call it like
C++
::AfxMessageBox()
 
Share this answer
 
Comments
kutz 2 15-Dec-11 4:26am    
Ok I agree with your answer.But what will be the second case
Resmi Anna 15-Dec-11 6:58am    
there is chance that in ur project a global function called DisplayMessage() and a class member function called DisplayMessage() exists. so to resolve the conflict between this when called from the class.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900