【发布时间】:2021-09-04 01:03:44
【问题描述】:
我已经创建了一个构造函数,但是为什么仍然有一个错误“类没有默认构造函数”? 我已经搜索了这个问题的答案,但我仍然不清楚这个错误。有人可以帮我吗?
pragma once
#include<string>
using namespace std;
class Date
{
private:
int month;
int day;
int year;
public:
Date(int newmonth, int newday, int newyear)
{
month = newmonth;
day = newday;
year = newyear;
}
};
class Student
{
private:
string name;
Date birthDay;
int score;
public:
Student(string newname, Date newbirthDay, int score)
{
}
};
【问题讨论】:
标签: c++ constructor