c++ - 编译器错误“class_name”不是类型,“class_name”没有命名类型 C++
问题描述
我不明白为什么我会收到这个错误。当我创建构造函数时,它显示此错误“包”不是类型或“包”没有命名类型,如果我删除构造函数,它会编译。
#include <iostream>
#include "bag.h"
using namespace std;
#ifndef PLAYER_H
#define PLAYER_H
class player {
string name;
bag *bag;
public:
player(string, bag *);
};
player::player(string name = "DEFAULT_NAME", bag *bag = NULL)
{
this->name = name;
this->bag = bag;
}
#endif /* PLAYER_H */
Bag 类工作正常并且可以编译,但是一旦我尝试使用 bag 类创建构造函数,我就会收到此错误。
解决方案
推荐阅读
- assembly - X86: `movsxd rdx,edx` 指令是什么意思?
- database - 我可以以某种方式提供额外的上下文以允许 postgres 有效地排序/限制视图而不计算它们的行吗?
- java - 创建自定义参数匹配器混淆实现
- testflight - 上传到 TestFlight 时,Fastlane 获得“train_version 不再是 FastlaneCore 消息中使用的参数”
- javascript - 如何将道具从 connect 的 HOC 传递到 HOC?
- google-bigquery - 查询失败并出现错误 RESOURCE_EXHAUSTED (ORDER BY without ORDER BY)
- docker - Ubuntu18.04下默认无法安装nvidia-docker2
- typescript3.0 - TypeScript const 断言:如何使用 Array.prototype.includes?
- angular - Angular 6 kendo-dropdownlist 有条件地设置 [valueField] 和 [textField]
- dart - Google Rest API:“无效的 JWT:观众检查失败”?我正在使用观众字段 API 建议