Hi,
I was wondering if there's s a clean way to do this:
- assume we have class A and B
- class B has a member 'SetThingie(const int pValue)'
- class A has a vector of class B
- class A has a 'current B' int
- class A has a member 'SetThingie(const int pValue)', same as class B
- when class A SetThingie is called, it should call SetThingie of the class B object in the vector, with index 'current B'
Now the most straigt forward you would be something like this:
class ClassA { public: void SetThingie(const int pValue); private: int currentIndex; std::vector<ClassB> mObjects; } class ClassB { public: void SetThingie(const int pValue); } void ClassA::SetThingie(const int pValue) { mObjects[currentIndex].SetIndex(pValue); }
Do you think there are easier/ cleaner ways to do this?
What about intefacing the Effect with Shader?
class ShaderBase {
public:
virtual void setWorldMatrix(MATRIX &matrix) = 0; //-- For interface class.
void SetIndex(int &value);
std::vector<ShaderBase> ShaderArray;
int currentIndex;
private:
};
class Effect : public ShaderBase {
public:
void setWorldMatrix(MATRIX &matrix); //-- Because shader base has a function called setWorldMatrix(MATRIX &) you overwrite the virtual function in ShaderBase
private:
}
Or are you talking about using inheritences in classes? I thought interfacing was what you're looking for because of the SetThingy thingy thing example.