У меня есть класс, и дружественная функция outer(...).
template <unsigned int columns>
class Perceptron {
public:
Perceptron(double norma, int flag, std::vector<std::tuple<int, bool>> function);
private:
auto net(int step) ->double;
auto f(double netParam)->bool;
auto learning(std::vector<std::tuple<int, bool>> & function, bool printOut)->bool;
auto step(int step)->void;
auto logisticFunction(double netParam)->double;
friend auto outer(const int& errors, const int& epochCount, const Perceptron<columns>* obj)->void;
int flag;
double norma;
std::vector<std::tuple<int, bool>> function;
std::vector<double> weights;
template <unsigned int columns>
auto Perceptron<columns>::learning(std::vector<std::tuple<int, bool>> & function, bool printOut)->bool {
int epochCount = 0, errors = 1;
while (errors != 0) {
if (epochCount > 40) return false;
errors = 0;
for (int i = 0; i < pow(2, columns - 1); i++) {
std::bitset<columns> bits(i + pow(2, columns - 1));
if (std::get<1>(this->function[i]) != f(net(i)))
errors++;
}
if (printOut)
outer(errors, epochCount, this);
for (int i = 0; i < this->function.size(); i++)
this->step(i);
epochCount++;
}
return true;
}
template <unsigned int columns>
auto outer(const int& errors, const int& epochCount, const Perceptron<columns>* obj)->void {
std::cout << "Epocha " << epochCount << ":\nY = (";
for (size_t i = 0; i < obj->function.size(); i++)
std::cout << obj->f(obj->net(std::get<0>(obj->function[i]))) << ((i == (pow(2, columns - 1) - 1)) ? "),\n" : ",");
std::cout << "W = (";
for (int i = 0; i < columns; i++)
std::cout << obj->weights[i] << ((i == columns - 1) ? "), " : ",");
std::cout << "E = " << errors << "\n";
}
Ошибка:
Ошибка LNK2019 ссылка на неразрешенный внешний символ "void __cdecl outer(int,int,class Perceptron<5> *)" (?outer@@YAXHHPAV?$Perceptron@$04@@@Z) в функции "private: bool __thiscall Perceptron<5>::learning(class std::vector,class std::allocator > &,bool)" (?learning@?$Perceptron@$04@@AAE_NAAV?$vector@V?$tuple@H_N@std@@V?$allocator@V?$tuple@H_N@std@@@2@@std@@_N@Z) ITIB1 c:\Users\kudas\source\repos\ITIB1\ITIB1\ITIB1.obj 1
out(*this)