我试图创建一个头文件中定义的自定义对象的向量,然后在实际的cpp文件中初始化它们.我在Visual Studio中遇到以下错误:
error C2976: 'std::vector' : too few template arguments
error C2065: 'Particle' : undeclared identifier
error C2059: syntax error : '>'
Run Code Online (Sandbox Code Playgroud)
在下面的代码中,向量在Explosion.h中定义.
#pragma once
class Particle : public sf::CircleShape {
public:
float speed;
bool alive;
float vx;
float vy;
Particle(float x, float y, float vx, float vy, sf::Color color);
~Particle();
};
Run Code Online (Sandbox Code Playgroud)
#include <SFML/Graphics.hpp>
#include "Particle.h"
Particle::Particle(float x, float y, float vx, float vy, sf::Color color) {
// Inherited
this->setPosition(x, y);
this->setRadius(5);
this->setFillColor(color);
// Player Defined Variables
this->speed …Run Code Online (Sandbox Code Playgroud)