error C2065: 'Block' : undeclared identifier c:\users\dylan\documents\visual studio 2013\projects\pong\containerofblocks.h 10 1 Pong
error C2923: 'std::vector' : 'Block' is not a valid template type argument for parameter '_Ty' c:\users\dylan\documents\visual studio 2013\projects\pong\containerofblocks.h 10 1 Pong
error C2065: 'Block' : undeclared identifier c:\users\dylan\documents\visual studio 2013\projects\pong\containerofblocks.h 17 1 Pong
error C2923: 'std::vector' : 'Block' is not a valid template type argument for parameter '_Ty' c:\users\dylan\documents\visual studio 2013\projects\pong\containerofblocks.h 17 1 Pong
Hey guys, these are my errors. I am not quite sure what code to include. So I will include anything linked the containerOfBlocks. The problem arose when I
#include "containterOfBlocks.h"
inside the collisionHandler class I made.
collisionHandler.h
#include "Stdafx.h"
#ifndef COLISSION_HANDLER
#define COLISSION_HANDLER
class ColisionHandler
{
public:
ColisionHandler();
~ColisionHandler();
void hasBallHitSides(Ball& ball, int windowWidth);
void hasBallHitTop(Ball& ball);
void hasBallHitPaddle(Ball& ball, Paddle& paddle);
void hasPaddleHitSides(Paddle& paddle, int windowWidth);
void HasBallHitRow(Ball& ball, ContainerOfBlocks& blockContainer, SoundHandler& soundHandler);
};
#endif
collisionHandler.cpp
#include "Stdafx.h"
#include "containerOfBlocks.h"
#include "ball.h"
#include "paddle.h"
#include "soundHandler.h"
#include "colisionHandler.h"
ColisionHandler::ColisionHandler()
{
}
ColisionHandler::~ColisionHandler()
{
}
block.cpp
#include "Stdafx.h"
#include "block.h"
Block::Block(float startX, float startY)
{
position.x = startX;
position.y = startY;
colour = sf::Color::White;
block.setSize(sf::Vector2f(width, height));
block.setFillColor(colour);
}
Block::~Block()
{
}
sf::RectangleShape Block::getBlock()
{
return block;
}
sf::FloatRect Block::getPosition()
{
return block.getGlobalBounds();
}
void Block::draw(sf::RenderWindow& window)
{
window.draw(block);
}
void Block::setPosition(int yPosition)
{
position.y = yPosition;
block.setPosition(position);
}
void Block::setColour(sf::Color tempColour)
{
colour = tempColour;
block.setFillColor(colour);
}
containerOfBlocks.h
#ifndef CONTAINER_OF_BLOCKS
#define CONTAINER_OF_BLOCKS
class ContainerOfBlocks
{
public:
ContainerOfBlocks(int yPosition, sf::Color colour);
~ContainerOfBlocks();
std::vector<Block>& getContainer();
size_t getSize();
void drawContainer(sf::RenderWindow& window);
void deleteObjectFromVector(int objectNumber);
private:
std::vector<Block> blockContainer;
};
#endif
containerOfBlocks.cpp
#include "Stdafx.h"
#include "block.h"
#include "containerOfBlocks.h"
ContainerOfBlocks::ContainerOfBlocks(int yPosition, sf::Color colour)
{
blockContainer.push_back(Block(2, 2));
blockContainer.push_back(Block(104, 2));
blockContainer.push_back(Block(206, 2));
blockContainer.push_back(Block(308, 2));
blockContainer.push_back(Block(410, 2));
blockContainer.push_back(Block(512, 2));
blockContainer.push_back(Block(614, 2));
blockContainer.push_back(Block(716, 2));
blockContainer.push_back(Block(818, 2));
blockContainer.push_back(Block(920, 2));
for (unsigned int i = 0; i < 10; ++i)
{
blockContainer[i].setPosition(yPosition);
}
for (unsigned int i = 0; i < 10; ++i)
{
blockContainer[i].setColour(colour);
}
}
ContainerOfBlocks::~ContainerOfBlocks()
{
}
std::vector<Block>& ContainerOfBlocks::getContainer()
{
return blockContainer;
}
void ContainerOfBlocks::drawContainer(sf::RenderWindow& window)
{
for (unsigned int i = 0; i < blockContainer.size(); ++i)
{
blockContainer[i].draw(window);
}
}
void ContainerOfBlocks::deleteObjectFromVector(int objectNumber)
{
blockContainer.erase(blockContainer.begin() + objectNumber);
}
size_t ContainerOfBlocks::getSize()
{
return blockContainer.size();
}
I know this is a lot of code guys. But I appreciate any sort of help
sorry I do not have a clue what has gone on!