Содержимое указанного файла (плюс #includes и определения основного файла):
CalculatorFunctions.hpp
Код: Выделить всё
#pragma once
#include
namespace cf
{
double add(double a, double b);
double subtract(double a, double b);
double multiply(double a, double b);
double subtract(double a, double b);
double power(double a, double b);
long factorial(long a);
double strIntoLong(std::string &s, int &decimalSeparatorLoc);
}
Код: Выделить всё
#include "CalculatorFunctions.cpp"
#include "CalculatorFunctions.hpp"
#include
#include
#include
Код: Выделить всё
#include "CalculatorFunctions.hpp"
#include
using namespace cf;
double add(double a, double b) { return (a + b); }
double subtract(double a, double b) { return (a - b); }
double multiplication(double a, double b) { return (a * b); }
double divide(double a, double b) { return (a / b); }
double power(double a, double b) { return pow(a, b); }
long factorial(long a)
{
long length = a;
a = 1;
for (int i = 0; i < length; i++)
{
a *= (length - i);
}
return a;
}
double strIntoDouble(std::string &s, int &decimalSeparatorLoc)
{
double num = 0;
for (int i = 0; i < s.length(); i++)
{
num *= 10;
num += (s[i] - 48);
}
num /= pow(10, (s.length() - decimalSeparatorLoc));
return num;
}
double strIntoLong(std::string &s, int &decimalSeparatorLoc)
{
double constructedNum;
for (int i = 0; i < s.size(); i++)
{
constructedNum *= 10;
constructedNum += (s[i] - 48);
}
constructedNum /= (s.size() - decimalSeparatorLoc);
}
Код: Выделить всё
Undefined symbols for architecture arm64:
"cf::strIntoLong(std::__1::basic_string&, int&)", referenced from:
tokenizeInput(std::__1::basic_string const&) in CalculatorMain-c59961.o
ld: symbol(s) not found for architecture arm64
потому что я ДЕЙСТВИТЕЛЬНО связал свои файлы правильно, я трижды проверил его И пропустил через отладчик AI, и он не обнаружил никаких несоответствий.>
Подробнее здесь: https://stackoverflow.com/questions/797 ... der-file-c
Мобильная версия