Udało się, ale przy próbie napisania kolejnej funkcji, mam nie spotykany wcześniej błąd.
Dołączyłem plik nagłówkowy <algorithm> i dostałem błędy:
error C1903: unable to recover from previous error(s); stopping compilation
error C2064: term does not evaluate to a function taking 2 arguments
Co zrobić?
kod:
#ifndef Header.h
#define Header_h
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct ocena
{
string przedmiot;
int wartosc;
};
struct indeks
{
string imie;
string nazwisko;
vector <ocena> oceny;
};
void pobierz (vector <indeks> &ind, int n);
void wyswietl (const vector <indeks> &ind, int n);
bool porownaj(vector <indeks> &ind);
void sort (vector <indeks> &ind);
#endif
#include "Header.h"
bool porownaj(vector <indeks> &ind)
{
indeks s1, s2;
if (s1.imie<s2.imie)
return true;
else return false;
}
void sort (vector <indeks> &ind)
{
sort(ind.begin(), ind.end(), porownaj(ind));
}
void pobierz (vector <indeks> &ind, int n)
{
indeks x;
ocena o;
cin>>x.imie>>x.nazwisko;
for (int i=0; i<n; i++)
{
cout<<"Podaj przedmiot: ";
cin>>o.przedmiot;
cout<<"Podaj ocene: ";
cin>>o.wartosc;
x.oceny.push_back(o);
}
ind.push_back(x);
}
void wyswietl (const vector <indeks> &ind, int n)
{
for (auto v=ind.begin(); v!=ind.end(); ++v)
{
cout<<(*v).imie<<" "<<(*v).nazwisko<<endl;
for(auto w=v->oceny.begin(); w!=v->oceny.end(); ++w)
cout<<(*w).przedmiot<<": "<<(*w).wartosc<<endl;
}
}