void CVisualStudioDemoDoc::updateLine(void)
{
int newln = GetLineNumber(p_buf);
reinterpret_cast<CVisualStudioDemoView *>(m_viewList.GetHead())->SetCurrentLineNumber(ln, newln);
ln = newln;
}
I want to call this function from another part of my code without having to give the object pointer and include headers.
I want to call it just like a normal void function.
if (changementLigne == true) {
currentLine = prog;
// TODO : appeler le callback de X2
updateLine();
Suspendre();
changementLigne = false;
}
I dont know if it’s possible, since the CVisualStudioDemoDoc class is an MFC class, I didn’t find a pointer I can use.
You can’t do this.
If a member function refers to member variables, it needs a valid
thispointer. If you don’t include the header file that declares the function, the compiler can’t know what you’re referring to. How can it know thatupdateLine()is a function unless you tell it?If you’re trying to call a C++ member function from C code then you need to write a wrapper. Something like the following (not tested):
.h file:
.cpp file:
There are other questions that might be helpful as well.