Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Leda > Help me, What's...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 151 of 212
Post > Topic >>

Help me, What's different? (empty interface inheritance)

by kanam@[EMAIL PROTECTED] (kanam) Aug 17, 2004 at 10:33 PM

i want to use class member function pointer.
i did as below case. but this program terminates with runtime error.

interface ICtlBase
{
   virtual ~ICtlBase(){};
   virtual void SetName(CString strData) = 0;
   virtual void SetID(CString strData) = 0;
};

class CCtlBase : public ICtlBase
{
public:
   virtual ~CCtlBase();
   virtual void SetName(CString strData);
   virtual void SetID(CString strData);

   typedef void (CCtlBase::*SetFunction)(CString);

   void ExeFunc(SetFunction);
};

void CCtlBase::ExeFunc(SetFunction func)
{
   SetFunction setFunction = func;
   this->*setFunction("aaaa");
}

class CCtlEdit : public CEdit, public CCtlBase
{
public:
   virtual ~CCtlEdit();
   virtual void SetText(CString strText);

   void Test();
};

void CCtlEdit ::Test()
{
   ExeFunc(SetText);
}

when this program run CCtlEdit::Test, this program terminate with runtime
error.

but i modified this program as below.

interface IBase   // empty interface
{
};

interface ICtlBase : public IBase
{
   virtual ~ICtlBase(){};
   virtual void SetName(CString strData) = 0;
   virtual void SetID(CString strData) = 0;
};

To my surprise, modified program work well.
only ICtlBase inherits empty interface IBase.

What happened? 

please Let me know this  situation.




 1 Posts in Topic:
Help me, What's different? (empty interface inheritance)
kanam@[EMAIL PROTECTED]   2004-08-17 22:33:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 4:24:33 CDT 2008.