【发布时间】:2020-08-13 19:09:11
【问题描述】:
https://imgur.com/gallery/pEw8fBs https://pastebin.com/xvWFHrTU
我的错误贴在上面..我不明白这段代码有什么问题..我正在尝试构建一本书,里面有一个日期对象。请帮忙,这也是我的第一篇文章! :)
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
inline void keep_window_open() { char ch; cin >> ch; }
class Date {
int y, m, d;
public:
Date(int d, int m, int y);
};
class Book {
string title;
string author;
string isbn;
Date date;
public:
Book(string t, string a, string id, Date d);
};
int main() {
Book Charlie("charlie", "gates", "333H", Date(1, 2, 3));
}
【问题讨论】:
-
我不确定我是否曾在此站点上看到过作为编译器错误的 imgur 链接。
-
请将错误作为文本包含在问题内(不是通过链接)TIA
-
您还没有实现任何一个构造函数(已声明但未定义)。
-
在 C++ 中,尽可能将参数设为
const,尤其是作为参考。string t复制一份。const string& t没有。