Итак, я хочу вернуть карту из узла, который находится внутри BST, если он совпадает с целевым значением (карта с годом), а затем вернуть карту в класс.
Я пытался использовать указатели на функции, и я не понимаю, почему я могу заставить их работать в моем main.cpp, но не в классе. Что касается этого возвращаемого значения, я пробовал это раньше и сейчас получаю эту ошибку
Error C2672 'operator __surrogate_func': no matching overloaded function found Simple Read Date c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xutility 3084
Error C2893 Failed to specialize function template 'unknown-type std::equal_to<void>::operator ()(_Ty1 &&,_Ty2 &&) const' Simple Read Date c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xutility 3084
main.cpp
DataCollection dc;
typedef map<int, map<int, vector<WeatherLog>>> typeMap;
dc.client_call(dataMap,tree);
TBST.h
template <class T>
T& TBST<T>::Search(T target)
{
return SearchPrivate(root, target);
}
template <class T>
T& TBST<T>::SearchPrivate(Node* ptr, T target)
{
if (root != nullptr && ptr != nullptr)
{
if (ptr->key > target)
SearchPrivate(ptr->left, target);
else if (ptr->key < target)
SearchPrivate(ptr->right, target);
else if (ptr->key == target)
return ptr->key;
}
else
{
std::cout << "No target data found\n";
}
}
DataCollection.cpp
typedef map<int, map<int, vector<WeatherLog>>> typeMap;
typedef map<int, vector<WeatherLog>> innerMap;
//This is what im trying to get to work
typeMap oneYear;
typeMap returnOneYear;
innerMap empty;
oneYear[year] = empty;
returnOneYear = tree.Search(oneYear);
WeatherLog.h
struct WeatherLog {
Date d;
Time t;
float speed;
float sRads;
double airTemp;
};
поэтому я просто хочу, чтобы поиск мог возвращать карту, возвращающуюся в returnOneYear