所以,我有一些我是定義類,它給了我這個錯誤:沒有匹配函數調用[類]
#include <iostream>
using namespace std;;
//void makepayment(int amount, string name, Date date);
//void listpayments();
class Date;
class Date {
public:
int month;
int day;
int year;
Date(int month, int day, int year) {
this->month = month;
this->day = day;
this->year = year;
}
};
class Payment {
public:
int amount;
string name;
Date date;
Payment(int amount, string name, Date date) {
this->amount = amount;
this->name = name;
this->date = date;
}
};
int main() {
cout <<
"|~~~~~~~~~~~~~~~~~~~~~~~~| \n" <<
"| WELCOME TO THE | \n" <<
"| WESSLES BANK | \n" <<
"| MANAGEMENT SYSTEM! | \n" <<
"|~~~~~~~~~~~~~~~~~~~~~~~~| \n";
for(;;) {
}
return 0;
}
錯誤是:
foo.cpp: In constructor ‘Payment::Payment(int, std::string, Date)’:
foo.cpp:26:49: error: no matching function for call to ‘Date::Date()’
foo.cpp:26:49: note: candidates are:
foo.cpp:14:5: note: Date::Date(int, int, int)
foo.cpp:14:5: note: candidate expects 3 arguments, 0 provided
foo.cpp:9:7: note: Date::Date(const Date&)
foo.cpp:9:7: note: candidate expects 1 argument, 0 provided
我不知道什麼是錯的! '沒有匹配的通話功能'是什麼意思?
對不起,如果這是一個noobie問題...我剛開始C++。
好。謝謝!我主要是一名java程序員。剛剛開始C++ tody:P。 – user1766728
沒問題。用C++玩得開心! – Aesthete