Need Help Passing an Array as a Parameter
Code:
#include <Windows.h>
struct BaseClass
{
private:
protected:
public:
virtual void ReservedFunction() {}
};
template <typename TYPE> struct DerivedClass : public BaseClass
{
private:
protected:
public:
TYPE Value;
template <typename TYPE> DerivedClass(const TYPE & in__Source) : Value(in__Source) {}
};
template <typename TYPE> TYPE ConvertParameter(BaseClass * in__Source)
{
DerivedClass<TYPE> * ReturnValue = dynamic_cast<DerivedClass<TYPE> *>(in__Source);
return ReturnValue->Value;
}
template <typename TYPE> DerivedClass<TYPE> * BuildParameter(const TYPE in__Source)
{
DerivedClass<TYPE> * ReturnValue = new DerivedClass<TYPE>(in__Source);
return ReturnValue;
}
struct ArrayFunction
{
private:
protected:
public:
ArrayFunction(BaseClass ** in__Array)
{
in__Array++;
}
};
int main()
{
BaseClass * Array[3];
Array[0] = BuildParameter<int>(14);
Array[1] = BuildParameter<double>(5.2);
Array[2] = BuildParameter<char *>("string");
ArrayFunction Function(Array);
return 0;
}
I am able to make an array with any values using smart pointers and dynamic_cast. But the only problem I am having is that I am not able to use the array index when I pass it into a function. I am currently using the increment operator ++ to move through the list but I would like use the array index to move through it.