I wrote a simple 'base' class and I then had a vector of 'base' objects.I then created 10 base objects.I then wanted to ouput the contents of it using a iterator.How do i do it? i get error.
Code:
class base{ /*simple base class*/
private:
int status;
public:
int getStatus(){
return status;
}
base(int num){
status =num;
}
};
int main(void){
vector<base> the_vector;
vector<base>::iterator the_iterator;
/*INPUT AND CREATE BASE OBJECTS OF VALUES 1 to 10*/
for( int i=1; i < 11; i++ ){
base a(i);
the_vector.push_back(a);
}
/*OUTPUT 1 to 10*/
the_iterator = the_vector.begin();
while( the_iterator != the_vector.end() ) {
cout<<the_vector.getStatus()<<endl; //ERROR LINE
the_iterator++;
}
}
it must be a silly error i guess.
thanx