[英]error: 'Date' does not name a type?
我知道這可能是一個簡單的問題,但是我已經搜索了幾個小時,無法解決。 我精簡了項目,使查找問題更加容易,這是我的代碼:
日期.h
#ifndef DATE_H
#define DATE_H
Date{
private:
int day;
int month;
int year;
public:
Date();
Date(int, int, int)
};
#endif // DATE_H
Date.cpp
#include <iostream>
#include "Date.h"
using namespace std;
Date::Date(){
day = 0;
month = 0;
year = 0;
}
Date::Date(int day, int month, int year){
this->day = day;
this->month = month;
this->year = year;
}
main.cpp
#include <iostream>
#include "Date.h"
using namespace std;
int main()
{
Date d1(14, 2, 15);
return 0;
}
在Date.h
您錯過了聲明前面的class
關鍵字。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.