Получение множества ошибок, и они очень загадочные.
Вот весь соответствующий код:
// 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:";
for (it=mylist.begin(); it!=mylist.end(); ++it)
cout << it->texture << endl;
cout << endl;
mylist.sort(compare_nocase);
cout << "after sort mylist contains:";
for (it=mylist.begin(); it!=mylist.end(); ++it)
cout << it->texture << endl;
cout << endl;
return 0;
}
Я просто тестирую функцию сортировки STL, но получаю ошибки:
c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(12): error C2380: type(s) preceding 'texture' (constructor with 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 as right side of '.' operator
1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(18): error C2274: 'function-style cast' : illegal as right side of '.' operator
1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(35): error C2274: 'function-style cast' : illegal as right side of '.' operator
1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(39): error C2274: 'function-style cast' : illegal as right side of '.' operator
1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(43): error C2274: 'function-style cast' : illegal as right side of '.' operator
1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(51): error C2273: 'function-style cast' : illegal as right side of '->' operator
1>c:\users\spaniel\documents\visual studio 2010\projects\list\list\main.cpp(59): error C2273: 'function-style cast' : illegal as right side of '->' operator