chercher une valeur avec find
bonjour,
je voudrais supprimer les string de ajouterarejeter qui apparaissent dans struct_bulletin.mentioncandidat[i] pour i de 0 à 5
je ne comprends pas pourquoi find ne veut pas du vector presentmention:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| //enumetstruct.hpp
#ifndef ENUMETSTRUCT_HPP
#define ENUMETSTRUCT_HPP
#include <string>
#include <vector>
enum unitelexicale {candidats,bulletins,virgule,deuxpts,mot,TB,B,AB,P,I,AR,finbulletin,fin,personne,FDF};
struct occurence_bulletin{
std::vector<std::string>candidatmention[6];//Candidats ayant la même mention
};
#endif |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #ifndef SCRUTIN_HPP
#define SCRUTIN_HPP
#include <map>
#include <vector>
#include "syntaxique.hpp"
class scrutin{
public:
scrutin(std::string nomfichier);
std::string elu();
private:
syntaxique S;
bool presenceerreur;
unsigned int nbvotants;
std::map<std::string,int[6]> scores;
std::vector<std::string>vec_nomscandidats;
std::vector<occurence_bulletin> vec_listebulletins;
void absentarejeter();
void calculscore();
bool calculexeco();
void supprmedian();
};
#endif |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #include <iostream>
#include <string>
#include <vector>
#include "scrutin.hpp"
scrutin::scrutin(std::string nomfichier):S(nomfichier){
S.anasynt(vec_nomscandidats,vec_listebulletins,presenceerreur);
absentarejeter();
}
void scrutin::absentarejeter(){
std::vector<std::string>ajouterarejeter;
ajouterarejeter=vec_nomscandidats;
for(auto nom:vec_nomscandidats)
for(auto struct_bulletin:vec_listebulletins)
for(int i=0;i<6;i++){
std::vector<std::string> presentmention;
presentmention=struct_bulletin.candidatmention[i];
if(find(presentmention.begin(),presentmention.end(),nom) != presentmention.end())
ajouterarejeter.erase(find(ajouterarejeter.begin(),ajouterarejeter.end(),nom));
}
} |
Code:
1 2 3
| scrutin.cpp: In member function void scrutin::absentarejeter():
scrutin.cpp:20:16: error: no matching function for call to find(std::vector<std::__cxx11::basic_string<char> >::iterator, std::vector<std::__cxx11::basic_string<char> >::iterator, std::__cxx11::basic_string<char>&)
20 | if(find(presentmention.begin(),presentmention.end(),nom) != presentmention.end()) |
quelqu'un a une idée?