GameObjectをタイル、プレーヤー、敵、壁のすべてから作成しようとしています。私は私のクラスのCharacter(ParentをPlayerクラスとEnemyクラスの2つのクラスに追加)を基本クラスGameObjectにしようとしています。文字のコンストラクタを作成しようとすると、C2512エラーがCharacter.cppファイルに発生します。誰かが私が間違っていることを指摘できますか?前もって感謝します。'GameObject':適切なデフォルトのコンストラクタがありません
Characters.h
#ifndef CHARACTERS_H
#define CHARACTERS_H
#include <cstdlib>
#include <ctime> /*cstdlib and ctime are used to help with the pseudo randomness for events*/
#include <cstdio> /*allows remove function*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <array>
#include <string>
#include <vector>
#include "GameObject.h"
using namespace std;
class Character : public GameObject{
public:
Character();
~Character();
virtual void attack(vector<Character *>&characters) = 0;
void set_values(string nam, int hp, int str, int mag) {
name = nam;
health = hp;
strength = str;
magic = mag;
};
string name;
int health;
int strength;
int magic;
};
#endif
GameObject.h
#ifndef GAMEOBJECCT_H
#define GAMEOBJECT_H
#include "Direct3D.h"
#include "Mesh.h"
#include "InputController.h"
class GameObject {
protected:
Vector3 m_position;
float m_rotX, m_rotY, m_rotZ;
float m_scaleX, m_scaleY, m_scaleZ; //Not really needed for A1.
//Used for rendering
Matrix m_world;
Mesh* m_mesh;
Texture* m_texture;
Shader* m_shader;
InputController* m_input; //Might have enemies who react to player input.
float m_moveSpeed;
float m_rotateSpeed;
public:
//Constructor
GameObject(Mesh* mesh, Shader* shader, InputController *input, Vector3 position, Texture* texture);
~GameObject();
void Update(float timestep);
void Render(Direct3D* renderer, Camera* cam);
Characters.cpp
#include "Characters.h"
#include <cstdlib>
#include <ctime> /*cstdlib and ctime are used to help with the pseudo randomness for events*/
#include <cstdio> /*allows remove function*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <array>
#include <string>
#include <vector>
using namespace std;
void Character::attack(vector<Character *>&characters) {};
Character::Character() {
};
Character::~Character() {};
は 'GameObject'が意図またはここに安全な行動であるにデフォルトコンストラクタを追加するようにしていません。私はR Sahuが意思のお金の上にあると思う。 – EyasSH
助けてくれてありがとう。未解決の外部シンボルであるもう一つのより簡単なエラーが発生しました。それは通常あなたが何か正しいものを含んでいないときですか? – Zone
@Zone新しいデフォルトコンストラクタを実装しましたか?あなたがそうしなければ、確かにそれは未解決のシンボルエラーを引き起こすでしょう。 –