Passing values of a two dimensional vector

I want to be able to have a function which passes the value of the vector, one column at a time. In my code I call these functions Get functions:
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _CREADOUT_H
#define _CREADOUT_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <math.h>
#include <iomanip>
#include <utility>
#include <vector>

using namespace std;
  
class Test {
  static int i;
  static int j;
 static vector<int> vec; ///returns values of vec just fine
 static vector< vector<int> > nest; ///only returns zeros and not what values it actually holds
 static int ary[300];
  static int GetVec(int h) { return vec[h]; } 
  static int GetNest(int a) { return nest[a][i];}
 public:
  Test();
  ~Test(){};      
  static void PhillVec();
  static void TransferVec();  
  static void PhillBuffer();
};

#endif

void Test::PhillVec() {
 vec.resize(10); 

    double random;
     for( int a=0; a<vec.size(); a++) { 
	  random = rand() % 10000;
	  double value = random/10000;  
	
    if( value < .5 ) vec[a]=1 ; 
	else vec[a]=0;
   
	   }
   for (int j=0;j<vec.size();j++) {
   	   cout<< "vec " << j << "= " << vec[j] <<endl;  
    }
}

void Test::TransferVec () {
 nest.resize(10); 
 
 for(int l=0;l<vec.size();l++)  {
       nest[l].resize(10);
        if(GetVec(l)==1){
        nest[l][i]=1; ///every time function is run i increases, so fill vector up one column pre run 
    }
else{
     nest[l].erase(nest[l].begin()+i);   ////this statement is also not working, i would like it to delete the vector space if it is not 1
    }
cout<<"nest= "<<nest[l][i]<<endl;
} 
    i++;
}

void Test::PhillBuffer(){
    for(int m=0;m<vec.size();m++){
  
        if(GetNest[m][i]==1){ ////this function is not working correctly
         ary[j]=1   ;
         j++;
        }   
    }
}

Test::Test(){
 for(int t=0;t<10;t++){
  PhillVec();
  TransferVec();   
  PhillBuffer(); 
}
}

int Test::j=0;
int Test::i=0;
vector<int> Test:: vec;
vector< vector<int> > Test:: nest;

int main() {
 srand( time(NULL) );
 Test();  
}


The GetVec() function does not seem to return any correct value, does anyone know a better way to pass values of 2d vector, which is in a similar method of my code. i.e. one column per run. Also I can't seem to get get my erase function to work, which is there to remove any entry that is not 1.
Last edited on
Topic archived. No new replies allowed.