私はこのクラスのためにこのコードを作成していますが、エラーの意味や修正方法はわかりません。また、私は次のステップが何であるか、あるいはどのようにしてプログラムを完成させることができないのか分かりません。私は1ヶ月間C++を使用していましたが、私はあまりそれに慣れていません。前もって感謝します!atoiとエラーの使用:未解決の外部シンボル
error LNK2019: unresolved external symbol "int __cdecl parseDate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" ([email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function _main
: fatal error LNK1120: 1 unresolved externals
私の割り当ては次のとおりです。
駐車場は、最大3時間駐車する$ 2.00最低料金を課金します。ガレージは3時間を超えて毎時または1時間あたり0.50ドルの追加料金を請求します。特定の24時間の最大料金は$ 10.00です。 24時間以上車を駐車する人は、1日あたり8.00ドルを支払うでしょう。
駐車料金を計算して印刷するプログラムを作成します。あなたのプログラムへの入力は、車が駐車場に入る日時と、同じ車が駐車場を離れる日時です。 YY/MM/DDのHH:両方の入力がの形式になっていミリメートル
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;
string startDateString;
string endDateString;
string dateStr;
int parseDate(string dateStr);
int main()
{
string enter_date;
string enter_time;
string exit_date;
string exit_time;
cout << "Please enter the date and time the car is entering "<< endl
<< "the parking garage in the following format: YY/MM/DD hh:mm"<< endl;
getline (cin,dateStr);//cin >> enter_date >> enter_time;
cout<< "Please enter the date and time the car is exiting "<< endl
<< "the parking garage in the following format: YY/MM/DD hh:mm"<< endl;
getline (cin,dateStr);//cin >> exit_date >> exit_time;
{
// Format: YY/MM/DD hh:mm
int year = atoi(dateStr.substr(0, 2).c_str());
int month = atoi(dateStr.substr(3, 2).c_str());
int day = atoi(dateStr.substr(6, 2).c_str());
int hour = atoi(dateStr.substr(9, 2).c_str());
int min = atoi(dateStr.substr(12, 2).c_str());
// Now calculate no. of mins and return this
int totalMins = 0;
totalMins += (year * 365 * 24 * 60);
totalMins += (month * 30 * 24 * 60);
totalMins += (day * 24 * 60);
totalMins += (hour * 60);
totalMins += (min);
return totalMins;
}
int startTime = parseDate(startDateString);
int endTime = parseDate(endDateString);
int elapsedTime = endTime - startTime; // elapsedTime is no. of minutes parked
return 0;
}
あなたのコードのフォーマットが間違っている、あなたははparsedataを定義していませんfunction –