Почему компоновщик ругается на повторное определение функций при компиляции кода с оптимизацией?
При запуске программы с оптимизацией компоновщик ругается на повторное определение функций, с чем это связано и как можно решить возникшую проблему?
#include <iostream>
#include <fstream>
#include <ctime>
#include <string>
#include <math.h>
#include <time.h>
#define SIZE 1000000
using namespace std;
template <typename T>
void Generation(T* arr, T xmin,T xmax)
{
for (int i = 0; i < SIZE; i++)
{
arr[i] = 100 + static_cast <T> (rand()) /( static_cast <T> (RAND_MAX/(200-100)));
}
//Choise_Function(arr);
}
void Choise_Type()
{
cout << "\tВыберите тип данных:\n1) int\n2) double\n3) float\n";
int type;
cin >> type;
switch(type)
{
case 1:
{
int *arr_int = nullptr;
arr_int = new int[SIZE];
Generation(arr_int, 1, 100);
}
break;
case 2:
{
double *arr_doub = nullptr;
arr_doub = new double[SIZE];
Generation(arr_doub, 0.0, 100.0);
}
break;
case 3:
{
float *arr_fl = nullptr;
arr_fl = new float[SIZE];
Generation(arr_fl, 0.f, 100.f);
}
break;
}
}
int main()
{
srand(time(NULL));
setlocale(0, "rus");
while(1)
{
int work;
cout << "1) Старт\n2) Выход" << endl;
cin >> work;
switch(work)
{
case 1:
{
Choise_Type();
}
break;
case 2:
return 0;
default:
break;
}
}
return 0;
}