I am trying to sort a vector of integers using std::sort. I'm quite new to C++ so there might be a basic error. This is my header file so far:
class MaximumGates {
private:
int maxGates;
public:
int maximumGates(const vector<int> &arrivesIn, const vector<int> &departsIn);
};
int maximumGates(const vector<int> &arrivesIn, const vector<int> &departsIn){
int maxDeparture = *std::max_element(departsIn.begin(), departsIn.end());
sort(departsIn.begin(), departsIn.end());
return maxDeparture;
}
It is accessed in the main() method as such:
#include "MaximumGates.h"
#include <iostream>
using std::cout;
using std::endl;
#include <vector>
using std::vector;
int main() {
int retval = 0;
{
vector<int> arrives{360, 400, 700};
vector<int> departs{900, 515, 780};
int maxGates = maximumGates(arrives,departs);
...
Upon compiling, there are 20+ errors e.g.
/Applications/http://ift.tt/2y3mIxU: note:
candidate template ignored: could not match 'shared_ptr<type-parameter-0-0>' against
'const int'
swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT
^
/Applications/http://ift.tt/2hTDo71: note:
candidate template ignored: could not match 'weak_ptr<type-parameter-0-0>' against
'const int'
swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Aucun commentaire:
Enregistrer un commentaire