Click here to Skip to main content
15,901,373 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can I install Platform SDK for Visual Studio 6.0 on XP SP3? Pin
Stefan7626-Nov-09 2:11
Stefan7626-Nov-09 2:11 
GeneralRe: How can I install Platform SDK for Visual Studio 6.0 on XP SP3? Pin
Rajesh R Subramanian26-Nov-09 5:22
professionalRajesh R Subramanian26-Nov-09 5:22 
AnswerRe: How can I install Platform SDK for Visual Studio 6.0 on XP SP3? Pin
Michael Schubert25-Nov-09 11:33
Michael Schubert25-Nov-09 11:33 
GeneralRe: How can I install Platform SDK for Visual Studio 6.0 on XP SP3? Pin
Erik25-Nov-09 11:58
Erik25-Nov-09 11:58 
Questionhow to make winapi control "edit" transparent? Pin
nenfa25-Nov-09 5:07
nenfa25-Nov-09 5:07 
AnswerRe: how to make winapi control "edit" transparent? Pin
Richard MacCutchan25-Nov-09 6:53
mveRichard MacCutchan25-Nov-09 6:53 
AnswerRe: how to make winapi control "edit" transparent? Pin
«_Superman_»25-Nov-09 9:26
professional«_Superman_»25-Nov-09 9:26 
GeneralRe: how to make winapi control "edit" transparent? Pin
nenfa25-Nov-09 19:09
nenfa25-Nov-09 19:09 
QuestionMFC print preview???? Pin
kk_Kevin25-Nov-09 2:09
kk_Kevin25-Nov-09 2:09 
AnswerRe: MFC print preview???? Pin
Nelek30-Nov-09 1:35
protectorNelek30-Nov-09 1:35 
QuestionCant see out put of file at compile time Pin
andean196125-Nov-09 0:37
andean196125-Nov-09 0:37 
AnswerRe: Cant see out put of file at compile time Pin
Adam Roderick J25-Nov-09 0:41
Adam Roderick J25-Nov-09 0:41 
GeneralRe: Cant see out put of file at compile time Pin
Tim Craig25-Nov-09 14:48
Tim Craig25-Nov-09 14:48 
AnswerRe: Cant see out put of file at compile time Pin
Richard MacCutchan25-Nov-09 7:01
mveRichard MacCutchan25-Nov-09 7:01 
AnswerRe: Cant see out put of file at compile time Pin
Stefan7625-Nov-09 10:15
Stefan7625-Nov-09 10:15 
QuestionLoading PDF file in picture control Pin
Pryabu25-Nov-09 0:17
Pryabu25-Nov-09 0:17 
QuestionHow can I restrict a CListViewCtrl for column resizing . Pin
pandit8424-Nov-09 23:52
pandit8424-Nov-09 23:52 
AnswerRe: How can I restrict a CListViewCtrl for column resizing . Pin
Adam Roderick J25-Nov-09 0:06
Adam Roderick J25-Nov-09 0:06 
AnswerRe: How can I restrict a CListViewCtrl for column resizing . Pin
JohnCz7-Dec-09 18:45
JohnCz7-Dec-09 18:45 
Questionconvert wav file to text file Pin
soo preety24-Nov-09 23:43
soo preety24-Nov-09 23:43 
AnswerRe: convert wav file to text file [modified] Pin
Adam Roderick J24-Nov-09 23:52
Adam Roderick J24-Nov-09 23:52 
AnswerRe: convert wav file to text file Pin
«_Superman_»25-Nov-09 8:35
professional«_Superman_»25-Nov-09 8:35 
QuestionReplacing virtual function address with global function address Pin
abhay4u24-Nov-09 21:54
abhay4u24-Nov-09 21:54 
Hi,

I've created a class containing a virtual function. Using pointer, I want to replace virtual function with a global function, but it gives memory access violation. So my question is that

whether it is possible to replace virtual function with global function?
How can we achieve this?

Please note that I am new to C++ and using MS VC++.

Here is the code...
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef void(*Fun)();
void f(void *pThis)
{
printf("other function\n");
}

class Test {
public:
virtual void fn() {
cout << "I m virtaul fn" << endl;
}

virtual ~Test() {}
};

int main() {
Test obj;
Fun pFun = (Fun)*(int*)*(int*)(&obj);
pFun();

//replacing virtual function.
int *pInt = (int*)&obj;
*(int*)*pInt = (int)f; // gives memory voilation

pFun = (Fun)(int*)*(int*)*(int*)(&obj);
pFun();
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
Thank you
AnswerRe: Replacing virtual function address with global function address Pin
Cedric Moonen24-Nov-09 22:02
Cedric Moonen24-Nov-09 22:02 
AnswerRe: Replacing virtual function address with global function address Pin
Adam Roderick J24-Nov-09 22:13
Adam Roderick J24-Nov-09 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.