Original Post
I'm having difficulties inserting Struct data into Vector. What I'm trying to do, is to insert Particle structs to vector inside Particle class, but I'm getting weird errors: Particle.obj : error LNK2001: unresolved external symbol __imp___CrtDbgReportW fatal error LNK1120: 1 unresolved externals The errors didn't tell anything on what line the error were. Here is some code if it helps: Particle.h Particle.cpp
#pragma once
#include "Texture.h"
#include <string>
#include <iostream>
#include <vector>
using namespace std;
struct Particle
{
float x, y;
float velX, velY;
float alpha;
};
class CParticle
{
public:
CParticle( int x1, int x2, int y1, int y2, int amount, string texturePath );
void UpdateParticles( float deltaTime );
void DrawParticles();
void SetX1(int x) { m_nCoordX1 = x; }
void SetX2(int x) { m_nCoordX1 = x; }
void SetY1(int y) { m_nCoordY1 = y; }
void SetY2(int y) { m_nCoordY2 = y; }
public:
~CParticle( void );
private:
Particle CreateParticle();
vector <Particle> m_particleList; // <- here is where i'd like to store Particle structs
CTexture* m_particleTexture;
int m_nAmount;
int m_nCoordX1;
int m_nCoordY1;
int m_nCoordX2;
int m_nCoordY2;
};
#include "Particle.h"
CParticle::CParticle( int x1, int x2, int y1, int y2, int amount, string texturePath )
{
m_particleTexture = new CTexture( texturePath.c_str() );
m_nCoordX1 = x1;
m_nCoordY1 = y1;
m_nCoordX2 = x2;
m_nCoordY2 = y2;
m_nAmount = amount;
for (int i = 0; i < m_nAmount; i++)
{
m_particleList.push_back( CreateParticle() ); // Here I insert the new particles to vector
}
}
CParticle::~CParticle(void)
{
delete m_particleList;
}
Particle CParticle::CreateParticle()
{
Particle particle;
srand( (unsigned)time( NULL ) );
particle.x = (float)((rand() % 130) + 5);
particle.y = (float)((rand() % 130) + 5);
particle.velX = (float)(rand() % 20) - 10.0f;
particle.velY = (float)-(rand() % 30) - 20.0f;
particle.alpha = (rand() % 100) / 100.0f;
return particle;
}
void CParticle::UpdateParticles( float deltaTime )
{
}
void CParticle::DrawParticles()
{
}