Error in C++ list::sort -


getting bunch of errors , cryptic.

here's relevant code:

// list::sort #include <iostream> #include <list> #include <string> #include <cctype> #include "main.h"  using namespace std;  struct texture {     int texture;     int ref; };  bool compare_nocase (texture first, texture second) {     if(first.texture < second.texture)     {         return true;     }     else     {         return false;     } }  int main () {   list<texture> mylist;   list<texture>::iterator it;    texture moose;   moose.ref = 3;   moose.texture = 6;    texture moose2;   moose2.ref = 1;   moose2.texture = 3;    texture moose3;   moose3.ref = 2;   moose3.texture = 14;    mylist.push_back (moose);   mylist.push_back (moose2);   mylist.push_back (moose3);    cout << "before sort mylist contains:";   (it=mylist.begin(); it!=mylist.end(); ++it)       cout << it->texture << endl;   cout << endl;     mylist.sort(compare_nocase);    cout << "after sort mylist contains:";   (it=mylist.begin(); it!=mylist.end(); ++it)     cout << it->texture << endl;   cout << endl;    return 0; } 

i testing out stl sort function errors:

c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(12): error c2380: type(s) preceding 'texture' (constructor return type, or illegal redefinition of current class-name?) 1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(18): error c2274: 'function-style cast' : illegal right side of '.' operator 1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(18): error c2274: 'function-style cast' : illegal right side of '.' operator 1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(35): error c2274: 'function-style cast' : illegal right side of '.' operator 1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(39): error c2274: 'function-style cast' : illegal right side of '.' operator 1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(43): error c2274: 'function-style cast' : illegal right side of '.' operator 1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(51): error c2273: 'function-style cast' : illegal right side of '->' operator 1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(59): error c2273: 'function-style cast' : illegal right side of '->' operator 

you have struct member texture same name struct itself.

apparently vs 2010 doesn't this, although gcc 4.1.2 fine. i'm not sure correct...


Comments