Click here to Skip to main content
15,913,685 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralNeed a Reminder Application Source code Pin
deep_19814-Jan-05 22:04
deep_19814-Jan-05 22:04 
GeneralRe: Need a Reminder Application Source code Pin
David Crow5-Jan-05 5:20
David Crow5-Jan-05 5:20 
GeneralRe: Need a Reminder Application Source code Pin
deep_19816-Jan-05 4:22
deep_19816-Jan-05 4:22 
GeneralFile for Project settings Pin
Neelesh K J Jain4-Jan-05 21:12
Neelesh K J Jain4-Jan-05 21:12 
GeneralRe: File for Project settings Pin
ThatsAlok4-Jan-05 21:28
ThatsAlok4-Jan-05 21:28 
GeneralRe: File for Project settings Pin
Rajesh match4-Jan-05 21:32
Rajesh match4-Jan-05 21:32 
GeneralDisabling Scroll Bar in ListView Pin
Neelesh K J Jain4-Jan-05 21:06
Neelesh K J Jain4-Jan-05 21:06 
Generalpointer to a member function in a derived class Pin
sjcomp4-Jan-05 20:30
sjcomp4-Jan-05 20:30 
I want to be able to call a function from a derived class in a base class function using pointer to this function. Example using reinterpret_cast follows, but it does not compile using mingw Frown | :( So maybe someone can explain me what I can do in this situation? Maybe I can use function objects, if yes, then how and what would serve the best? Thanks in advance!

#include <iostream>
// forward declaration
struct func_struct;

class data {};// base data class

class mydata : public data // new data class
{
public:
int i; // one class member
};

class base // main functionality
{
public:
virtual func_struct* get_func()=0;
void dothings(data* pData);
};

typedef void (base::*func)(data *);
struct func_struct
{
func pfunc;
};

void base::dothings(data* pData)
{
func_struct* fs=get_func();
// how to get the pointer???
(this->*fs.pfunc)(pData);
};

// specific functions
class child : public base
{
public:
virtual func_struct* get_func()
{
static func_struct maping;
// how to store pointer???
maping.pfunc=reinterpret_cast<func>(my_func);
return &maping;
}
void my_func(mydata* p)
{
p->i=1;
}
};

int main(int argc, char *argv[])
{
mydata d;
std::cout<<d.i<<std::endl; // should be 0
child c;
c.dothings(&d);
std::cout<<d.i<<std::endl; // should be 1
return 0;
}


Regards,
Alexander.
GeneralEnabling Scrollbar in a disabled listbox Pin
laavsjj4-Jan-05 19:42
laavsjj4-Jan-05 19:42 
GeneralRe: Enabling Scrollbar in a disabled listbox Pin
KaЯl4-Jan-05 21:21
KaЯl4-Jan-05 21:21 
GeneralTraffic Control APIs Error!!!! Invalid parameter Pin
dharani4-Jan-05 19:16
dharani4-Jan-05 19:16 
GeneralRestricted Execution Pin
pc_dev4-Jan-05 19:15
pc_dev4-Jan-05 19:15 
GeneralRe: Restricted Execution Pin
BlackDice5-Jan-05 6:15
BlackDice5-Jan-05 6:15 
GeneralRe: Restricted Execution Pin
pc_dev6-Jan-05 16:06
pc_dev6-Jan-05 16:06 
GeneralDisable Text Box in dialog Box Pin
Rajesh_K_Sharma4-Jan-05 18:32
Rajesh_K_Sharma4-Jan-05 18:32 
GeneralRe: Disable Text Box in dialog Box Pin
PJ Arends4-Jan-05 19:03
professionalPJ Arends4-Jan-05 19:03 
GeneralRe: Disable Text Box in dialog Box Pin
John R. Shaw5-Jan-05 9:13
John R. Shaw5-Jan-05 9:13 
GeneralRe: Disable Text Box in dialog Box Pin
Member 15087325-Jan-05 0:24
Member 15087325-Jan-05 0:24 
GeneralI need some pointer help please Pin
fklldsvs4-Jan-05 17:29
fklldsvs4-Jan-05 17:29 
GeneralRe: I need some pointer help please Pin
ThatsAlok4-Jan-05 18:54
ThatsAlok4-Jan-05 18:54 
GeneralRe: I need some pointer help please Pin
John R. Shaw5-Jan-05 9:29
John R. Shaw5-Jan-05 9:29 
Questionhow can i play audio that use vivo's siren codec Pin
stephen_yeerwu4-Jan-05 15:31
stephen_yeerwu4-Jan-05 15:31 
QuestionHow can I share data which contain pointers between processes? Pin
berserkerr4-Jan-05 14:39
berserkerr4-Jan-05 14:39 
AnswerRe: How can I share data which contain pointers between processes? Pin
KaЯl4-Jan-05 21:26
KaЯl4-Jan-05 21:26 
AnswerRe: How can I share data which contain pointers between processes? Pin
Blake Miller5-Jan-05 5:09
Blake Miller5-Jan-05 5:09 

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.