I'm writing some code where I defined the following base class.
class Chorus{
public:
//Destructor
virtual ~Chorus();
//callback function
virtual int callback( void *outputBuffer, void *notUsed, unsigned int
nBufferFrames, double streamTime, RtAudioStreamStatus status, void *userData );
virtual void initializeDelayBuffer(void);
virtual void destroyDelayBuffer(void);
};
I want to use this as a base class and not actually do anything with it on its own. So I have two seperate classes which are derived from this class Chorus. I wanted to do this to simply provide some basic constraints as to what any derived Chorus class MUST have to be considered usable in my program.
When I build my project (Visual Studio 2008), I get unresolved external symbol errors on all the virtual functions from this Chorus class. I'm guessing it's the typical error where I didn't make forward declarations of these functions. But, since they are virtual and I don't want them to actually be defined to do anything until they are defined within the deriving classes, what do I do to resolve this issue?
If your intent is for them to be simply place holders for child classes to implement, then make them pure virtual functions by ending with = 0. For example
virtual void destroyDelayBuffer(void) = 0;
This makes the method "abstract" so to speak. The C++ compiler will not look for an actual definition of the method but instead will force all derived classes to implement these methods before an instance can be created.