Hey, I am trying to create a capacity for my array in the public section of my class and it keeps giving me the same error "illegal pure syntax, must be '= 0' ". Here is my header code. The problem is apparently under the public section.
thanksCode:#include <iostream> using namespace std; class List { public: typedef int VALUE_TYPE; const int CAPACITY = 30; VALUE_TYPE array[CAPACITY]; List(); //constructor List(List& x); //copy constructor //void destroy(); //void assign(); void remove(); //destroy operation void first(); //first operation void next(); //next operation void prev(); //previous operation void Makecurrent(int x); //makecurrent operation VALUE_TYPE current(); //shows current position VALUE_TYPE examine(); //examine operation void replace(VALUE_TYPE v); //replace operation VALUE_TYPE insertafter(VALUE_TYPE v); //insert after operation VALUE_TYPE insertbefore(VALUE_TYPE v); //insert before operation VALUE_TYPE size(); //Count operation friend ostream & operator<<(ostream& out, List x) { for(int i=0;i<CAPACITY;i++) out << x.array[i] << " "; } friend ostream & operator+(List x, List y) { for(int i=0;i<CAPACITY;i++) x.array[i] + y.array[i]; } private: VALUE_TYPE pos; VALUE_TYPE used; VALUE_TYPE array[CAPACITY]; }; List::List() { pos=0; used=0; for(int i=0;i<CAPACITY;i++) array[i]=0; } List::List(List& x) { pos=x.pos; used=x.used; for(int i=0;i<CAPACITY;i++) array[i]=x.array[i]; } void List::remove() { VALUE_TYPE i; if(used!=0 && used<CAPACITY) { i=pos; while(i<=used && i<CAPACITY) { array[i]=array[i+1]; i++; } // if(pos > used) // pos=used; } } void List::first() { pos=array[0]; } void List::next() { while(pos < used && pos >= 0) pos++; } void List::prev() { while(pos < used && pos >=0) pos--; } List::Makecurrent(int x) { pos=x; if((pos > used) && (pos < 0)) if(pos>used) {pos=used;} if(pos<0) {pos=0;} } List::VALUE_TYPE List::current() { if((pos <= used) && (pos > 0)) { return pos; } else { return 0; } } VALUE_TYPE List::examine() { VALUE_TYPE x,i; i=pos; x=array[i]; return x; } void List::replace(VALUE_TYPE v) { VALUE_TYPE x; array[x]=v; } VALUE_TYPE List::insertafter(VALUE_TYPE v) { /*if(used>CAPACITY) return 0; for(int i=used;i>pos;i--) mylist[i+1]=mylist[i]; pos++; mylist[pos+1]=v; used++; return 1; */ return v; } VALUE_TYPE List::insertbefore(VALUE_TYPE v) { return v; } VALUE_TYPE List::size() { return used; }



LinkBack URL
About LinkBacks


