#include <string>
#include <algorithm>
#include <iostream>
struct Tnode {
char* word;
int count;
Tnode* left;
Tnode* right;
Tnode(const std::string&, int);
~Tnode() { delete[] word; }
};
Tnode::Tnode(const std::string& s = {}, int i = {}) : count{ i }, left{ nullptr }, right{ nullptr } {
word = newchar[s.size()+1];
std::copy(s.begin(), s.end(), word); //<------------- Something wrong here ???
word[s.size()] = '\0';
}
int main() {
Tnode node{"bear", 50};
return 0;
}
For some reason compiler doesn't like this line std::copy(s.begin(), s.end(), word);
and here is the error message
Severity Code Description Project File Line
Error C4996 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' exercise_8 c:\program files (x86)\microsoft visual studio 14.0\vc\include\xutility 2230
Microsoft don't like a number of standard functions so they throw this warning when you use some functions they don't like. They want you to use different functions.