Hello!

There is a code:

room.h

#ifndef ROOM_H #define ROOM_H #include <vector> #include <cstdlib> #include "point.h" using std::vector; class Room { private: int x; int y; int width; int height; vector<Point> points(); public: bool intersects(Room other); int area(); Room(int x_, int y_, int w, int h); Room(){;} Room(const Room &base){(*this) = base;} static Room random(int fWidth, int fHeight, int maxWidth, int maxHeight, int minWidth, int minHeight); friend bool operator==(Room a, Room b); Room operator=(const Room &base); }; #endif 

point.h

 #ifndef POINT_H #define POINT_H class Point { public: int x; int y; Point(int x_, int y_) { x = x_; y = y_; } Point() { ; } }; #endif 

maze.h

 #ifndef MAZE_H #define MAZE_H #include <vector> #include "room.h" using std::vector; enum Cell { Empty, Room, Path }; class Maze { Cell *field; bool *fog; int width; int height; int area; void putRooms(int count); vector<Room> rooms; public: Maze(int w, int h); void print(){} }; #endif 

When trying to compile, the compiler outputs:

 In file included from main.cpp:2:0: maze.h:27:13: error: type/value mismatch at argument 1 in template parameter lis t for 'template<class _Tp, class _Alloc> class std::vector' vector<Room> rooms; ^ maze.h:27:13: note: expected a type, got 'Room' maze.h:27:13: error: template argument 2 is invalid In file included from maze.cpp:1:0: maze.h:27:13: error: type/value mismatch at argument 1 in template parameter lis t for 'template<class _Tp, class _Alloc> class std::vector' vector<Room> rooms; ^ maze.h:27:13: note: expected a type, got 'Room' maze.h:27:13: error: template argument 2 is invalid 

In this case, if immediately after the vector<Rooms> rooms; in maze.h announce

 Point x; vector<Point> y; 

no more errors.

Explain, please, what is the difference for the compiler between Point and Room , and how to make the code compile?

    1 answer 1

    Your enumeration member is also named Room , which overlaps the Room class.

    Rename, use namespace or enum class .