So basically, I'm working on a project that can require both arrays and vectors to be passed through in order to calculate the final outcome. Now, I'm using the constructor to calculate the values and I need to know whether or not it is possible to change the datatype of the values depending of that what is passed through the constructor. Example:
class FFT {
public:
FFT(<array> &values_to_be_passed_through || <vector> &values_to_be_passed_through)
{
this->val = foo;
}
private:
vector/array vals_to_be_passed_through
};
int main(int argc, char *argv[]) {
int arr[] = {1, 2, 3, 4, 5, ......., 10};
FFT fft(arr); // this would work.
vector<int> values = {1, 2, 3, 4, 5, ......., 10};
FFT fft(values); // this would also work.
}
I know what the return type of the function would always be. i.e. in this case, it would be a complex (I've already wrote this) but I need to alternate to allow for multiple datatypes to be passed through.
Would this be possible using templates?
I hope someone can help me :)