C++中不允许使用限定名称,该名称已在C++17中编译
Qualified name is not allowed in C++, already compiling in C++ 17
我正在努力学习John Horton的Beginning C++Game Programming中的Zombie Arena项目。然而,皮卡给我带来了麻烦。
class Pickup
{
private:
//Start value for health pickups
const int HEALTH_START_VALUE = 50;
const int AMMO_START_VALUE = 12;
const int START_WAIT_TIME = 10;
const int START_SECONDS_TO_LIVE = 5;
// The sprite that represents this pickup
Sprite m_Sprite;
// The arena it exists in
IntRect m_Arena;
// How much is this pickup worth?
int m_Value;
// What type of pickup is this?
// 1 = health, 2 = ammo
int m_Type;
// Handle spawning and disappearing
bool m_Spawned;
float m_SecondsSinceSpawn;
float m_SecondsSinceDeSpawn;
float m_SecondsToLive;
float m_SecondsToWait;
// Public prototypes go here
public:
Pickup::Pickup(int type);
// Prepare a new pickup
void setArena(IntRect arena);
void spawn();
// Check the position of a pickup
FloatRect getPosition();
// Get the sprite for drawing
Sprite getSprite();
// Let the pickup update itself each frame
void update(float elapsedTime);
// Is this pickup currently spawned?
bool isSpawned();
// Get the goodness from the pickup
int gotIt();
// Upgrade the value of each pickup
void upgrade();
};
当我试图编译程序时,我在Pickup::Pickup(int type)
的成员声明错误中得到了一个非法的限定名。可能出了什么问题?我试过调试这个,但没有成功。请帮忙。我已经在用C++17进行编译了。
而不是构造函数的声明
Pickup::Pickup(int type);
写入
Pickup(int type);
构造函数声明的限定名是不正确的,尽管据我所知,一些编译器(如MSVS(允许这样的声明。
可以在类定义之外的成员函数定义中使用成员函数的限定名。
相关文章:
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- 代码块中无序多集的编译错误17.12
- 使用 C++17 编译特征需要_SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING定义
- 如何使用msbuild和设置C++17命令行编译Visual Studio项目?
- clang C++17 std::vector over align type 使用 -mavx 编译时元素 SIGSE
- C++17:在编译时将类型映射到整数值
- 为什么 'std::unary_function' 仍然在 c++17 中编译?
- c++17在编译时将带有已删除复制构造函数的类添加到std::vector
- 无法编译简单的C++17程序
- 在 RedHat Linux Enterprise Developer Workstation 上编译 C++17 代码
- 有没有办法在 C++17 中创建编译时类型映射以进行类型检查?
- 使用 C++17,如何创建类型到值的编译时图?
- C++17 在逗号上拆分 constexpr 字符串并在编译时有元素的数量?
- 使用 CLion、CMake 和 VS2017 编译器编译 C++17
- 为什么 GCC 和 clang 之间编译的 c++17 lambda 存在差异?
- gcc 可以使用较旧的第三方库编译 C++17 代码吗?
- 在使用 -std=c++17 编译时在 GCC 中复活 std::auto_ptr
- 如何在编译时检测C 17中是否没有虚拟基础
- 当我击中不良的constexpr时,请停止Visual Studio 17编译
- 使用ld: __stack_chk_guard@@GLIBC_2.17编译错误