473,804 Members | 3,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need clarification about virtual methods & inheritance

I have this class:
class Selections {
OSStatus Init();

protected:
CFMutableSetRef selectionObject s;
static void CFASelectionsAp plier(const void* value, void* ctx);
OSType ready;
public:
Selections();
Selections(cons t Selections &obj);
virtual ~Selections();

virtual OSType GetSelectionSco pe();

virtual UInt32 GetSelectCount( SelectionFlag whichFlags);
virtual CFArrayRef GetSelObjects(S electionFlag whichFlags);
UInt32 GetCountOfClass (SelObjectClass theClass);
CFArrayRef GetSelObjectsOf Class(SelObject Class theClass);
virtual UInt32 GetCountOfScope (OSType theScope);
virtual CFArrayRef GetArrayofScope (OSType theScope);

virtual OSStatus MassAddSelObjec ts(CFArrayRef sorArray);
virtual OSStatus AddSelectededOb ject(SelectedOb jectRef soref);
virtual OSStatus MassRemoveSelOb jects(CFArrayRe f sorArray);
virtual OSStatus RemoveSelectedO bject(SelectedO bjectRef soref);
virtual void RemoveAllSelect edObjects(Selec tionFlag whichFlags);
void RemoveSelObject sOfClass(SelObj ectClass theClass);
virtual void RemoveSelObject sOfScope(OSType theScope);
virtual void RemoveAll();
};

and a subclass:

typedef class DirView DirView;

class DVSelections: public Selections {
DirView* view;
OSType dvsReady;
public:
DVSelections(Di rView* theView);
DVSelections(co nst DVSelections &obj);
~DVSelections() ;

OSType GetSelectionSco pe();
DirView* GetView();
};

When I attempt to compile it, the linker complains with this message:
/usr/bin/ld: Undefined symbols:
vtable for DVSelections

I was under the impression if the virtual function is not defined in a
subclass, the parent class's function will be used.
What am I missing?

This is mac OS X, XCode 2.2 with gcc 4.

TIA
Mark
Jan 13 '06
10 2273
CodeSafe wrote:
Bahhh
if you want to create a pure virtual interface with pure virtual
destructor do
.h file:

class IMyPureVirtualC lass
{
public:
virtual ~IMyPureVirtual Class() = 0;

virtual void SomeInterfaceFu nction() = 0;
//...
};

.cpp file:
IMyPureVirtualC lass::~IMyPureV irtualClass()
{
//empty destructor (declared as pure virtual)
}


I tend to prefer a header only implementation:

public:
virtual ~IMyPureVirtual Class() = 0 {};


Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Jan 23 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1972
by: Jimmy Johns | last post by:
Hi all, I have some class hierarchy as follows: class S {}; class A {}; class B {public: vector<S*> v_; virtual ~B();}; class C : public virtual A, public virtual B { // do I need to define virtual ~C() so that B can be properly destructed?}; in fact, I don't even know if a destructor in C is even needed if I don't do
19
2352
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
8
2851
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl list class must Ioverride in order for this to work?
2
1780
by: Bonj | last post by:
Hello Can anyone assist with the following class hierarcy problem? I have a series of window classes, the object model currently being as such: Window / | \ / | \ MDIClientWindow | TreeViewWindow WndProcWindow / \
4
385
by: aap | last post by:
Hi, I have the following code. #include <iostream> using namespace std; class Root { public: virtual void Root1() = 0; virtual void Root2() = 0;
14
12155
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using events since I never saw it used anywhere in MSDN documentation/samples?! Or it will just break when I upgrade to .NET Framework 2.x in the coming years namespace MyNamespac public delegate void MyDel() public class MyBase public virtual...
3
4553
by: kikazaru | last post by:
Is it possible to return covariant types for virtual methods inherited from a base class using virtual inheritance? I've constructed an example below, which has the following structure: Shape = base class Triangle, Square = classes derived from Shape Prism = class derived from Shape TriangularPrism, SquarePrism = classes derived from Triangle and Prism, or Square and Prism respectively
4
2347
by: Stefan Nikolaus | last post by:
Hello, I've run into problems with defining a template, which inherits from a base template and the usage of virtual methods in those. I want to initialize a member variable depending on which template is created and I tried to define a virtual method, that's called from the base template ctor. Here's my example code: #include <iostream>
12
2666
by: mijobee | last post by:
I'm very new to c++ and just writing some code to learn. I've run into a problem, with a javaish design, and want to know if there is any possible solution without modifying the design. I've read up on virtual inheritance and from my understanding this should work fine but I haven't found any docs that use such a tangled example. The gcc output containing the errrors: Example.cpp: In member function 'virtual IObject*...
0
10580
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.