problems with class and vector


hi again every body
i really don't know how it is hard for me to compile and run those problem that i think i understand.
i have this code in my .hh file
1
2
3
4
5
6
7
8
9
10
11
class stuffList{
   public:


      void printProperties();
      void addMembers(stuff &item)
      stuffList();
   private:
      vector<stuff> elementList;
      int size;


and in my .cc file a have this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// default constructor 
stuffList::stuffList()
{

}

void stuffList::printProperties()
{
   vector<stuff>::iterator put;
   stuff mystuff ("erick",12);// intialisation of stuff object

   for ( put = elementList.begin(); put!= elementList.end(); ++put)
   {
      cout << mystuff.getStuffId() << endl;// trying to print th id only
   }

}
// storing new stuff
void stuffList::addMembers(stuff &item)
{
   elementList.push_back(item);
}


and in the main i have this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
   string dad;
   string mom;
   string onkle;
   string momie;


// intialising some stuff members
    stuff fs(dad,34);
    stuff f2(mom,21);
    stuff f3(onkle,12);
    stuff f4(momie, 24);

// intialisation of one stuffList
// to help me to store some stuff in the stuffList
   stuffList staffList();
   staffList.addMembers( fs);// storing the frist element 
   staffList.addMembers(f2);// storing the second element
   staffList.addMembers(f3);// storing the third element
   staffList.addMembers(f4);// storing the fourth element
   staffList.printProperties();
}

and here is my problem my addMembers () is not working and i don't know why i try so many different thing i m getting this error :
1
2
3
4
5
6
client.cc: In function 'int main()':
client.cc:26: error: request for member 'addMembers' in 'staffList', which is of non-class type 'stuffList ()()'
client.cc:27: error: request for member 'addMembers' in 'staffList', which is of non-class type 'stuffList ()()'
client.cc:28: error: request for member 'addMembers' in 'staffList', which is of non-class type 'stuffList ()()'
client.cc:29: error: request for member 'addMembers' in 'staffList', which is of non-class type 'stuffList ()()'
client.cc:30: error: request for member 'printProperties' in 'staffList', which is of non-class type 'stuffList ()()'


i m really confused please help me to understand this.
thank you in advance
Last edited on
The error is in line 16. You should write:
stuffList staffList;\

without the braces.
Last edited on
thanks man
i did see that one
Topic archived. No new replies allowed.