我需要創建字符串變量string time
,它應該看起來像14:58
。
我創建功能C++錯誤LNK2019
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)" ([email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@XZ) in _wmain
什麼問題,如何解決?
你在調用SetNumber/SetTime函數嗎? – billz
是的,我混淆了兩個功能,對不起。 – Heidel