我需要创建字符串变量string time
,它应该看起来像14:58
.
我创建了函数
string SetTime() {
long double h = (long double)(rand()%25);
long double m = (long double)(rand()%60);
string hour = to_string(h);
string minutes = (m <= 9 ? "0" : "" ) + to_string(m);
string time = hour + ":" + minutes;
return time;
}
但是当我尝试使用它时
string str = SetNumber();
cout << str;
我明白了
error LNK2019: link to unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl SetNumber(void)" (?SetNumber@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) in _wmain
出了什么问题以及如何解决?