Hej, mam taki kod programu.
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct person {
string name;
int age;
};
typedef person const &person_view;
namespace compare_person {
bool by_age(person_view lhs, person_view rhs) {
return lhs.age < rhs.age;
}
}
int main() {
person people[] = {
{"Jasiek ", 8},
{"Stasiek", 32},
{"Piotrek", 16},
{"Pawel", 11}
};
sort(begin(people), end(people), compare_person::by_age);
for(person_view person: people) {
cout << person.name << ": " << person.age << "\n";
}
return 0;
}
Kompilator daje mi następujące błędy:
Całkowicie nie rozumiem, co mam teraz zrobić, żeby program został skompilowany poprawnie? Pomożecie odszukać błędy?