Error C2259: cannot instantiate abstract class


#1

Hi everybody!

I am new to C++ and Juce but I need to use it for a Uni module. I have searched for similar errors/issues by other users but couldn't find an answer that may be able to fix my problem.

Long story short: I am trying to build a simple compressor but I get the forementioned error: 2259: cannot instantiate abstract class.

I am trying to build it with Visual Studio 2012 which points at the bolded lines, does anyone have any ideas as to what is causing the error?

I apologize if it sounds like a noob question but I really like Juce and would like to experiment with it but can't get past this...

 

Best,

M.

 

// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
    return new CompressorAudioProcessor();
}


int CompressorAudioProcessor::round(float inn)
{
    if (inn > 0) return (int) (inn + 0.5);
    else return (int) (inn - 0.5);
}
const String CompressorAudioProcessor::getName() const
{
    return JucePlugin_Name;
}
int CompressorAudioProcessor::getNumParameters()
{
    return 0;
}
float CompressorAudioProcessor::getParameter (int index)
{
    return 0.0f;
}
void CompressorAudioProcessor::setParameter (int index, float newValue)
{
}
const String CompressorAudioProcessor::getParameterName (int index)
{
    return String::empty;
}
const String CompressorAudioProcessor::getParameterText (int index)
{
    return String::empty;
}
const String CompressorAudioProcessor::getInputChannelName (int channelIndex) const
{
    return String (channelIndex + 1);
}
const String CompressorAudioProcessor::getOutputChannelName (int channelIndex) const
{
    return String (channelIndex + 1);
}
bool CompressorAudioProcessor::isInputChannelStereoPair (int index) const
{
    return true;
}
bool CompressorAudioProcessor::isOutputChannelStereoPair (int index) const
{
    return true;
}
bool CompressorAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
    return true;
#else
    return false;
#endif
}
bool CompressorAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
    return true;
#else
    return false;
#endif
}
int CompressorAudioProcessor::getNumPrograms()
{
    return 0;
}
int CompressorAudioProcessor::getCurrentProgram()
{
    return 0;
}
void CompressorAudioProcessor::setCurrentProgram (int index)
{
}
const String CompressorAudioProcessor::getProgramName (int index)
{
    return String::empty;
}
void CompressorAudioProcessor::changeProgramName (int index, const String& newName)
{
}
 


#2

Well, this error is a basic C++ one: you ain't filling out the pure-virtual methods from the base class (or classes). Any struct/class method marked with "= 0" at the end is stating that it is pure-virtual.

Your error should state which one(s). (Though MSVC errors are so damned ugly and take some getting used to - it may not be obvious.)


#3

I realize it might be an obvious one but I cannot figure it out. Here's the full error:


1>..\..\Source\PluginProcessor.cpp(172): error C2259: 'CompressorAudioProcessor' : cannot instantiate abstract class
1>          due to following members:
1>          'bool juce::AudioProcessor::silenceInProducesSilenceOut(void) const' : is abstract
1>          \res\juce\modules\juce_audio_processors\processors/juce_AudioProcessor.h(249) : see declaration of 'juce::AudioProcessor::silenceInProducesSilenceOut'
1>          'double juce::AudioProcessor::getTailLengthSeconds(void) const' : is abstract
1>          \res\juce\modules\juce_audio_processors\processors/juce_AudioProcessor.h(252) : see declaration of 'juce::AudioProcessor::getTailLengthSeconds'

Any thoughts?


#4

So, let me reword the error message, because the same error happens multiple times:

The class is still abstract, you need to fill out the following methods as they are missing:

- "bool juce::AudioProcessor::silenceInProducesSilenceOut(void) const"

- "double juce::AudioProcessor::getTailLengthSeconds(void) const"

Hopefully this will help get you going!


#5

Still no luck but I get the following error now:

Thoughts?


#6

http://stackoverflow.com/questions/1306778/c-virtual-pure-virtual-explained