Using a struct in my class

How do I integrate a struct I created into my class?
Here is my header file:
1
2
3
4
5
6
7
8
  struct Tetromino{
   std::string texture_file;
   sf::VertexArray squares_;
   // write a constructor taking a string and four vertices
   void Tetromino(std::string texture_file, sf::VertexArray squares_);
  };
...
//my class{} 


Then in my cpp file an error is thrown, saying that type name is not allowed when I try to add a struct object as a parameter.
 
   SetShape(Tetromino type);


How do I get my struct working with my class?
Show constext of using. If it is a declaration of function, where is return type? it it is a function call, why do you include type name along your variable?
SetShape() is a function call. I include type because it is an object parameter.
Do you call std::cout << 1; or std::cout << int 1;? Or maybe you do something like
1
2
int a[int 5];
a[int 2] = int 7;
?
If not, why did you write
SetShape(Tetromino type); it is equivalent to SetShape(int type); if we just change type in definition.
Ok so the error was fixed by removing Tetromino from the parameters in the function call, since Tetromino is a struct I have. The larger issue is that I'm having trouble implementing this struct into my class GamePiece. I have this header file
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
36
37
38
struct Tetromino{
   std::string filename;
   sf::VertexArray squares(sf::RectangleShape);
   // write a constructor taking a string and four vertices
   Tetromino(std::string filename, sf::VertexArray squares);
   ~Tetromino();
};

class GamePiece{
public:
	GamePiece(ImageManager &im, std::vector<sf::FloatRect> &levelCollisions);
	~GamePiece();

	void SetShape(Tetromino type);
	sf::Sprite &GetPieceSprite();

	void MovePiece(int x, int y);
	void RotateRight();
	void RotateLeft();

	std::vector<sf::RectangleShape> &GetPieceRectangles();
	const int SQUARE_SIZE = 10;
private:
	void MoveRects(int x, int y);

	ImageManager &imgr;

	std::vector<sf::FloatRect> &levelCollisions;

	sf::Sprite pieceShape;
	//1 = left, 2 = right
	int orientation;
	int originCount;
	//the sf::rectshapes will be program-wide, and their fr's will be created locally upon checking for collision
	std::vector<sf::RectangleShape> pieceRectangles_;
	//might be necessary if I acrue a shit ton of objects per piece
	//std::vector<sf::Transformable> pieceObjects;
};


and my goal is to have each object of GamePiece have one Tetromino object, but I don't know how to accomplish this.
Topic archived. No new replies allowed.