#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
using namespace std;
int vertices = 5;
int grid_x = 5;
int grid_y = 5;
struct pos_in_grid
{
int x_coordinate;
int y_coordinate;
};
map<pos_in_grid,int> grid_with_placement;
int initial_placement();
int main()
{
srand(time(NULL));
initial_placement();
return 0;
}
int initial_placement()
{
for(int i = 1;i<=vertices;)
{
pos_in_grid pos_of_node;
int j = rand()%grid_x;
pos_of_node.x_coordinate = j;
j = rand()%grid_y;
pos_of_node.y_coordinate = j;
if(grid_with_placement.find(pos_of_node) == grid_with_placement.end())
{
grid_with_placement[pos_of_node] = i;
i++;
}
else
{
continue;
}
}
return 0;
}
I have been writing this function for an assignment and I the task I intend to achieve is that I want to add to my if the entry is not already present in the map. However, I run into 2 errors and the terminal shows a bunch of text that I find hard to understand.
My question is 2 fold. First, 1. How do I rectify this issue. 2. If the command line shows a ton of errors where should I start from to get my issues rectified.
Error message is as below:
/Library/Developer/CommandLineTools/usr/include/c++/v1/__functional_base:55:21: error: invalid operands to binary expression ('const pos_in_grid' and 'const pos_in_grid')
{return __x < __y;}