• Advertisement
Sign in to follow this  

C++ Interfaces

This topic is 910 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking for some help. Basically, I am trying to make a class called RenderPackage, which would contain a shader and a few other items.
But for this example, I am focused on the shader part.
In the RenderPackage, the shader member  would be some type of shader. EG a default shader, a red light shader, and etc
Here I figured a Interface would work best, where all of my shaders would be able to implement this interface
So (I think) I made a interface for my shaders:

class IShader
   virtual ~IShader();
   virtual void Use() = 0;

Then I have my render package:

class RenderPackage
   IShader shader;

But I am getting an error for my RenderPackage class:
object of abstract class type "IShader" is not allowed. Function "IShader::Use" is a pure virtual function
So my question is:
How should I really be doing this? How can you use a Interface class as a member.
I was hoping I would be able to do something like:

DefaultShader defaultShader;
RenderPackage package;
package.shader = defaultShader;
//Down the line
Edited by noodleBowl

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement