0

I am trying to print out a chess board on the console. The data structure i am using is a set of pairs. I am having trouble accessing the pair's elements. I do realize a map is probably better in this case but i am using somebody else's code so I don't want to mess with it. Thanks in advance!

error i am getting says: error: 'struct std::_Rb_tree_const_iterator<const char*>' has no member named 'second'

Here is my code:

set< const pair<char, pair<int, int> >* > chosen;

for (int row=0; row<8; row++){
			for (int col=0; col<8; col++) {
				for (typename set<const A*>::iterator it = chosen.begin(); 
					 it != chosen.end(); it++) {
						if (*it->first=='B' 
							&& *it.second.first==row
							&& *it.second.second==col) {cout<<"B ";}
						else if (*it.first=='K' 
								 && *it.second.first==row
								 && *it.second.second==col) {cout<<"B ";}
						else {
								cout <<"_ ";
						}
					
					
				}
				cout <<"\n";
			}
		}

Edited by megatron21: n/a

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by gusano79
0

I see *it->first , but later on you have *it.second ; they can't both be right. It's a set of pointers to pairs, try *it->second .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.