c++ insert struct on set

hi all,
I am trying to insert a structure into a set but when I compile I am getting an error.

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
39
40
41
42
43
44
45
typedef struct pairData_
{   int index;
    string data;
    friend bool operator<(pairData_ const& a, pairData_ const& b)
    {
     return a.data.compare(b.data) !=0;
    }
}values;
...
pair<set<values::iterator,bool> ret_;

struct nodos
{
 int index;
 string attname;
 std::set <losdatos> domain;
 nodos *next;
};nodos *nfirst,*nlast,*nnewNodo,*ncurrent,*ntemp;


nfirst, ncurrent = NULL;

for(int j = 0; j < cols; j++){

 nnewNodo=new nodos;
 nnewNodo->next=NULL;
 nnewNodo->index = j;
 nnewNodo->attname = matrix[0][j];
 if(nfirst == NULL){
   nfirst=nnewNodo;
 }
 else{
   ncurrent->next=nnewNodo;
 }
 ncurrent=nnewNodo;
 int index = 0;
 values datos;
 for(int i = 1; i < rows; i++){
   datos.index = index++;
   datos.data = matrix[i][j];
   ret_ = ncurrent->domain.insert(datos);
   if (ret_.second==false)
	cout<< *ret_.first <<endl;
   }
 }


what i am doing wrong?
thx in advance

This is the error:
1
2
3
4
5
6
7
Dictionary.cpp:484:10: error: ‘iterator’ is not a member of ‘values’
Dictionary.cpp:484:10: error: ‘iterator’ is not a member of ‘values’
Dictionary.cpp:484:33: error: template argument 1 is invalid
Dictionary.cpp:484:33: error: template argument 3 is invalid
Dictionary.cpp:484:35: error: wrong number of template arguments (1, should be 2)
/usr/include/c++/4.5/bits/stl_pair.h:71:12: error: provided fortemplate<class _T1, class _T2> struct std::pair’

Class values has nothing called 'iterator' in it. In fact, value is not anything you can iterator over, so it would make no sense to put an iterator in it. Other problems are because you're missing one >. I suppose, if you put the > between "values" and "::", all of your problems will be solved...
hi hamsterman,
you are rigth about the > but this not resolve the problem.
i got this error:

1
2
 error: no match foroperator<<’ in ‘std::cout << ret_.std::pair<std::_Rb_tree_const_iterator<pairData_>, bool>::first.std::_Rb_tree_const_iterator<_Tp>::operator* [with _Tp = pairData_, const _Tp& = const pairData_&]()’
/usr/include/c++/4.5/ostream:108:7: note: candidates are: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]


My bet is that you don't have an operator << overloaded for pairData.
i am newbie on c++ and i don't know how to do it.
can you give me a tip how to do it?
thx in advance
Assume operator << is for output.

1
2
3
4
5
6
7
8
9
10
11
12
typedef struct pairData_
{   int index;
    string data;
    friend bool operator<(pairData_ const& a, pairData_ const& b)
    {
     return a.data.compare(b.data) !=0;
    }

    friend ostream& operator<<(ostream& o, const pairData& obj) {
      return o << obj.index << ":" << obj.data << "\n";
    }
}values;

Topic archived. No new replies allowed.