-1
나는 Chrono.cpp와 Chrono.h의 두 파일을 가지고 있습니다.C++ 클래스 생성자 혼동
Chrono.h
class Appointment {
public:
Appointment(Date d , string n) ;
Appointment() ;
int get_day() const { return date.d; }
int get_month() const { return date.m; }
int get_year() const { return date.y; }
string get_name() const { return name ; }
Date date ;
string name ;
} ;
Chrono.cpp는
Appointment::Appointment(Date dd , string nn)
: date(dd) , name(nn)
{
//if(!is_date(yy,mm,dd))throw Invalid();
}
나는이 오류가 계속하거나이 .H 파일과 일치 나던 말의 변화.
Chrono.cpp:17:1: error: prototype for āChrono::Appointment::Appointment(Chrono::Date, String)ā does not match any in class āChrono::Appointmentā
Chrono.h:34:7: error: candidates are: Chrono::Appointment::Appointment(Chrono::Appointment&&)
Chrono.h:34:7: error: Chrono::Appointment::Appointment(const Chrono::Appointment&)
Chrono.h:42:2: error: Chrono::Appointment::Appointment(Chrono::Date, std::string)
Chrono.h:41:2: error: Chrono::Appointment::Appointment()
두 파일 모두에 #include 문자열이 있고 .cpp 파일이 std 이름 공간에 있습니다. 나는 또한 헤더 파일에 std :: string을 사용하여 시도했다. 지금까지 내가 해낸 일은 아무 것도 없습니다. 어떤 도움을 주셔서 감사합니다. 또한 Date는 다른 곳에서 정의되고 올바르게 작동합니다.
컴파일러는이를 std :: string으로 인식하지 않으므로 String을 출력합니다. – Joshua
@Joshua :'Chrono.cpp' 파일에 * 리터럴 * 줄 17을 표시하십시오. –