non-lvalue in assignment

As the title suggests, this is the error I am getting "non-lvalue in assignment" on line 66.
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
#ifndef _CREADOUT_H
#define _CREADOUT_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <math.h>
#include <map>
#include <iomanip>
#include <utility>
#include <vector>

using namespace std;

class Test {
  static int one;
  static int i;
  static int j;
 static vector<int> vec;
 static vector< vector<int> > nest;
 static int ary[300];///////////////adjust buffer size
  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); //////////////////adjust vector size

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

void Test::TransferVec () {
 nest.resize(10); /////////////////////////adjust fifo size
 
 for(int l=0;l<vec.size();l++)  {
      nest[l].resize(10);/////////////////////////adjust fifo size
        if(GetVec(l)==1){
        nest[l][i]=1;
  
    }
} 
    i++;
}

void Test::PhillBuffer(){
    
    for(int a=0;a<vec.size();a++){
  
        if(nest[a][i-1]==1){
        1=ary[j];
         j++;
       }
    }   
cout<<j<<endl;
}


Test::Test(){
 for(int t=0;t<10;t++){
  PhillVec();
  TransferVec();   
  PhillBuffer(); 
}
}
int Test::one=1;
int Test::j=0;
int Test::i=0;
vector<int> Test:: vec;
vector< vector<int> > Test:: nest;

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

It doesn't like me assigning 1's into ary[j]. Any suggestions to fix this problem?
The assignment (=) operator makes the left side equal to the right. The right side is the constant 1, which can't be changed to be equal to whatever is at ary[j]. In other words, the constant 1 is not a proper l-value for the operator. You should just switch the order of the operands.
I did that but it then gives me a linker error that references the array on line 66.
What is the error?
[Linker error] undefined reference to `Test::ary'
Id returned 1 exit status
As you've declared ary as static, you also need the line

int Test::ary[300];

at file scope.

Same for all the other statics.

But why so many static members??
Last edited on
Thanks I can't believe I missed that, thanks. The static members are there because they conserve there value every time I loop the functions in Test::Test()
Topic archived. No new replies allowed.