gpt4 book ai didi

c++ - 错误 : 'Date' does not name a type?

转载 作者:行者123 更新时间:2023-11-28 02:43:08 25 4
gpt4 key购买 nike

我知道这可能是一个简单的问题,但我已经搜索了几个小时,但我无法解决它。我剥离了项目以便更容易找到问题,这是我的代码:

日期.h

#ifndef DATE_H
#define DATE_H

Date{
private:
int day;
int month;
int year;
public:
Date();
Date(int, int, int)
};

#endif // DATE_H

日期.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;
}

主要.cpp

#include <iostream>
#include "Date.h"
using namespace std;

int main()
{
Date d1(14, 2, 15);
return 0;
}

最佳答案

Date.h 中,您错过了声明前面的 class 关键字。

关于c++ - 错误 : 'Date' does not name a type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25276036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com