vector error (type)

what's wrong with my code (bold part) at Square.h.
why can't i declare a vector of type SIDE??

vector <SIDE> x;


Square.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef SQUARE_H_INCLUDED
#define SQUARE_H_INCLUDED
#include "Side.h"
#include <vector>
class SQUARE {
        float x, y, width;
        vector <SIDE> x;
    public:
        SQUARE();
        void setDimension(float _x,float _y, float _width);
        void drawSquare(RenderWindow *win);
        //void drawSymbol(float pl);
        bool isInside(float mouse_x, float mouse_y);
        int getX();
        int getY();
        int getSide();
};

#endif // SQUARE_H_INCLUDED


Square.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <SFML/Graphics.hpp>
#include "Square.h"

SQUARE::SQUARE(){

}

int SQUARE::getX(){
    return x;
}

int SQUARE::getY(){
    return y;
}

int SQUARE::getSide(){
    return width;
}

bool SQUARE::isInside(float mouse_x, float mouse_y){
    if(mouse_x >= x && mouse_x <= (x+width) && mouse_y >= y && mouse_y <+ (y+width))
        return true;
}

void SQUARE::drawSquare(RenderWindow *win){
    SIDE UpperH(x, y, x+width, y, win);
    SIDE LeftV(x, y+width, x, y, win);
    SIDE RightV(x+width, y+width, x+width, y, win);
    SIDE LowerH(x, y+width, x+width, y+width, win);
}
void SQUARE::setDimension(float _x,float _y, float _width){
    x = _x;
    y = _y;
    width = _width;
}


Side.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef SIDE_H_INCLUDED
#define SIDE_H_INCLUDED
#include <SFML/Graphics.hpp>
using namespace sf;

class SIDE {
        float x1,x2,y1,y2;
    public:
        SIDE(float _x1, float _y1, float _x2, float _y2,RenderWindow *win);

};


#endif // SIDE_H_INCLUDED 


Side.cpp

1
2
3
4
5
6
7
8
9
10
11
12
#include "Side.h"
using namespace sf;

SIDE::SIDE(float _x1, float _y1, float _x2, float _y2, RenderWindow *win){
    x1 = _x1;
    y1 = _y1;
    x2 = _x2;
    y2 = _y2;
    Shape side;
    side = Shape::Line(x1,y1,x2,y2,2,Color::Red);
    win->Draw(side);
}


Last edited on
std::vector
Topic archived. No new replies allowed.