请看下面的代码
游戏对象.cpp
#include "GameObject.h"
GameObject::GameObject(void)
{
id = 0;
}
GameObject::GameObject(int i)
{
id = i;
}
GameObject::~GameObject(void)
{
}
游戏对象.h
#pragma once
class GameObject
{
public:
GameObject(void);
GameObject(int);
~GameObject(void);
int id;
};
主文件
#include <iostream>
#include "GameObject.h"
using namespace std;
int main()
{
GameObject obj1;
cout << obj1.id << endl;
GameObject obj2(45);
cout << obj2.id << endl;;
system("pause");
return 0;
}
现在,我想确保无法使用默认构造函数定义 gameObject 类型的对象。我该怎么做?请帮忙!