convert problem

in main i have an error "cannot convert 'std::vector<std::vector<int>>' to '__gnu_cxx::__alloc_traits<std::allocator<int>>::value_type{aka int}' in assignment

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;

ifstream f("volumes_d_eau_distribues.txt");

vector<vector<int>>litTableauInt(string volumes_d_eau_distribues,int nb_colonnes){
          vector<vector<int>>t;
          int x;
          while(f){
             for(int i=0;i<50;i++)
                for(int j=0;j<nb_colonnes;j++){
                   if(f){
                      f>>x;
                      t[i][j]=x;
                 }}
             }
           return t;
          }

vector<int>colonne(vector<vector<int>>t,unsigned int i){
        vector<int> col;int x=0;
        for(unsigned int k=0;k<t.size();k++)
          for(unsigned int j=0;j<t.size();j++)
              if(j==i)
                col[x++]=t[k][i];
        return col;
}

int total(vector<int> t){
       int somme=0;
       for(unsigned int i=0;i<t.size();i++)
          somme=somme+t[i];
       return somme;
}

int main() {
      int nc;
      string volumes_d_eau_distribues;
      vector<vector<int>>t;
      while(f){
      for(unsigned int k=0;k<t.size();k++)
          for(unsigned int j=0;j<t.size();j++)
            t[k][j]=litTableauInt(volumes_d_eau_distribues, nc);
}
f.close();

}
Last edited on
Please edit your post and use code tags - http://www.cplusplus.com/articles/jEywvCM9/

t[k][j]=litTableauInt(string volumes_d_eau_distribues, nc);

1. Remove the word string from the parameter.
2. volumes_d_eau_distribues is not defined anywhere in main function. So it's not recognized.
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/180210/
Topic archived. No new replies allowed.