所以,我有一些我正在定义的类,它给了我错误:
#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
我不知道出了什么问题!'没有匹配的通话功能'是什么意思?
抱歉,如果这是一个菜鸟问题...我刚开始使用 C++。