Using interfaces and abstract classes
<p>I am have some trouble using interfaces in c++. I am currently learning OpenGL and I want to write an small OOP abstraction layer.</p>

<pre><code>#ifndef SHADER_H
#define SHADER_H

#include&lt;glload/gl_core.h&gt;
#include&lt;string&gt;
#include "filereader.h"
class IShader
{

public:
    virtual ~IShader(){}
    virtual void setShaderSource(std::string path) = 0;
    virtual bool createShader()= 0;
    virtual GLuint getHandle()= 0;
    virtual GLenum getShadertype()=0;
};
class BaseShader : public IShader
{

    GLuint shaderObj;
    std::string shaderSource;

public:

    virtual ~BaseShader();
    void setShaderSource(std::string path);
    bool createShader();
    GLuint getHandle();
    virtual GLenum getShadertype()=0;
};
class VertexShader : public BaseShader{
   public:

    GLenum getShadertype(){
        return GL_VERTEX_SHADER;
    }
};

class FragmentShader : public BaseShader{
public:
    GLenum getShadertype(){
        return GL_FRAGMENT_SHADER;
    }
};

class IShaderProgram{
public:
    virtual void attachShader(IShader &amp;s) = 0;
    virtual void link() = 0;
    virtual void use()=0;
};

#endif // SHADER_H
</code></pre>

<p>As you can see I created an IShader interface and an abstract class called BaseShader. Now I want to implement all methods in BaseShader except for <code>getShadertype()</code>. </p>

<p>But I somehow get forced to implement <code>getShadertype()</code> in BaseShader. If I don't do this I get an undefined reference error.</p>

<p>here is my shader.cpp</p>

<pre><code>#include "shader.h"

GLenum BaseShader::getShadertype(){
    return GL_VERTEX_SHADER; // I really don't want to implement getShadertype here
}

bool BaseShader::createShader(){
    BaseShader::shaderObj = glCreateShader(BaseShader::getShadertype());
    GLint length[1];
    length[0] = BaseShader::shaderSource.size();
    const GLchar* p[1];
    p[0] = BaseShader::shaderSource.c_str();
    glShaderSource(BaseShader::getHandle(),1,p,length);

    GLint success;
    glGetShaderiv(BaseShader::getHandle(), GL_COMPILE_STATUS, &amp;success);
        if (!success) {
            return false;
        }
    return true;


}
void BaseShader::setShaderSource(std::string path){
    FileReader fileReader(path);
    BaseShader::shaderSource = fileReader.get();
}

GLuint BaseShader::getHandle(){
    return BaseShader::shaderObj;
}
</code></pre>

<p><strong>How can I tell c++ that I only want to implement <code>getShadertype()</code> in VertexShader , FragmentShader etc?</strong></p>

<p>I probably messed up a lot of things, for example I can't even instantiate a Vertex or FragmentShader but I probably should ask another question for this.</p>
