#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>
usingnamespace std;
class Test {
staticint i;
staticint 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
staticint ary[300];
staticint GetVec(int h) { return vec[h]; }
staticint GetNest(int a) { return nest[a][i];}
public:
Test();
~Test(){};
staticvoid PhillVec();
staticvoid TransferVec();
staticvoid 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.