473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

virtual function problem

9
Hi,
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);
  5.  
  6.      void PacketHandler(struct pcap_pkthdr* pkt_header, const unsigned char* pkt_data);
  7.  
  8.     void WinpcapThreadEnded();
  9.  
  10.     bool m_capmaxperform;
  11. private:
  12.     CCaptureWindow* m_capwindow;
  13.     wxFrame* m_capframe;
  14. };
  15.  
in CaptureDoc.cpp
Expand|Select|Wrap|Line Numbers
  1. #include "CaptureDoc.h"
  2.  
  3. CCaptureDoc::CCaptureDoc(wxFrame* capframe, CCaptureWindow* capwindow)
  4. {
  5.    /* here some code */
  6. }
  7.  
  8. void CCaptureDoc::PacketHandler(struct pcap_pkthdr* packet_header, const unsigned char* packet_data)
  9. {
  10. /* here some code */
  11. }
  12.  
  13. void CCaptureDoc::WinpcapThreadEnded()
  14. {
  15.     /* here some code */
  16. }
  17.  
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. }
  7.  
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 :)

Thanks,
Adina
Mar 24 '07 #1
2 1160
adina
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 ?

Thanks,

Adina
Mar 24 '07 #2
adina
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.

Thanks,
Adina
Mar 24 '07 #3

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

Similar topics

18
by: nenad | last post by:
Wouldn't it be nice if we could do something like this: class Funky{ public: auto virtual void doStuff(){ // dostuff } };
3
by: Mark Turney | last post by:
Problem: I have a vector full of two different derived class objects (class B and class C) that are derived from the same base class A. I want to loop through vector and invoke a member function...
25
by: Stijn Oude Brunink | last post by:
Hello, I have the following trade off to make: A base class with 2 virtual functions would be realy helpfull for the problem I'm working on. Still though the functions that my program will use...
6
by: Dumitru Sipos | last post by:
Hello everybody! is there possible to have a function that is both static and virtual? Dumi.
11
by: santosh | last post by:
Hello, I was going through the Marshal Cline's C++ FAQ-Lite. I have a doubt regarding section 33.10. Here he is declaring a pure virtual destructor in the base class. And again defining...
5
by: Luke Dalessandro | last post by:
Code: Thread -> U -> T public class Thread { protected: thread_t _tid; virtual void foo() = 0; public: // Static entry function for the internal thread
8
by: Floogle | last post by:
how do i create a virtual == operator. I've tried the following but it's incorrect... class Interface { ... public: virtual bool operator==(const Interface& rhs)const=0;
6
by: pakis | last post by:
I am having a problem of pure virtual function call in my project. Can anyone explaine me the causes of pure virtual function calls other than calling a virtual function in base class? Thanks
17
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;"...
3
by: Markus Dehmann | last post by:
I have an abstract base class which contains a function that I would like to template, but virtual template functions are illegal. I put a mini code example below, which doesn't do anything great,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.