我目前正在一本书中完成一项任务,但我似乎很难创建一个实例。我会给你快速版本的代码。 另外,我是新来的,所以我很抱歉提前发现任何礼仪错误。
#include <iostream>
using namespace std;
class CShip
{
private:
int m_xPos;
int m_yPos;
int m_Energy;
public:
CShip();
}
// Constructor
CShip::CShip
{
m_xPos = 0;
m_yPos = 0;
m_Energy = 0;
}
int main()
{
// Pointer for the object
CShip *pPlayer = NULL;
// Create Instance on the Heap
// My problem: "Player" is marked as an error...';' was expected but every semicolon was set
pPlayer = new CShip Player;
return 0;
}