By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,925 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,925 IT Pros & Developers. It's quick & easy.

virtual function problem

P: 9
I have 2 classes in my application: class A and class B.
in CaptureDoc.h
Expand|Select|Wrap|Line Numbers
  1. class CCaptureDoc : public CWinpcap
  2. {
  3. public:
  4.     CCaptureDoc(wxFrame* capframe, CCaptureWindow* capwindow);
  6.      void PacketHandler(struct pcap_pkthdr* pkt_header, const unsigned char* pkt_data);
  8.     void WinpcapThreadEnded();
  10.     bool m_capmaxperform;
  11. private:
  12.     CCaptureWindow* m_capwindow;
  13.     wxFrame* m_capframe;
  14. };
in CaptureDoc.cpp
Expand|Select|Wrap|Line Numbers
  1. #include "CaptureDoc.h"
  3. CCaptureDoc::CCaptureDoc(wxFrame* capframe, CCaptureWindow* capwindow)
  4. {
  5.    /* here some code */
  6. }
  8. void CCaptureDoc::PacketHandler(struct pcap_pkthdr* packet_header, const unsigned char* packet_data)
  9. {
  10. /* here some code */
  11. }
  13. void CCaptureDoc::WinpcapThreadEnded()
  14. {
  15.     /* here some code */
  16. }
in winpcap.h
Expand|Select|Wrap|Line Numbers
  1. class CWinpcap : public wxThread, wxEvtHandler {
  2. /* ... code*/
  3. virtual void PacketHandler(struct pcap_pkthdr* pkt_header, const unsigned char* pkt_data);
  4. virtual void WinpcapThreadEnded(); 
  5. /* code */
  6. }
In winpcap.cpp member functions of the CWinpcap class are supposed to call the functions WinpcapThreadEnded() and PacketHandler()

I need the overriden functions in the derived class to get called by the base class and do their job. Is this the right way to solve this problem. However, I get an error LNK2001: unresolved external symbol....

If it cannot be done in this way, what would another way be ?
Any help would be very appreciated :)

Mar 24 '07 #1
Share this Question
Share on Google+
2 Replies

P: 9
An observation to the above post: I don't want the base class to know who is inheriting from it. Therefore I don't instantiate a derived class object or something like it. I suppose that you may see the functions overriden in the derived class as callback functions. Is this possible to be done ?


Mar 24 '07 #2

P: 9
Hello again,
I've been reading a little about the template method design pattern.
I have put the two virtual functions WinpcapThreadEnded() and PacketHandler() in the base class as protected.
The functions from the base class that call these two functions are public and non-virtual.

Stiil I receive the same linking errors: error LNK2001 unresolved external WinpcapThreadEnded() and unresolved external PacketHandler().

Any ideas to this problem are very much welcomed.

Mar 24 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.