CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Location
    Orange County, CA
    Posts
    99

    Exclamation Weird <vector> Error

    I am currently working on a program and I have come across an error that I am unsure about how to fix. Here is the section of code that it occurs in:

    Code:
     1: Customer* Store::remove(int num) {
     2: 	vector<Customer *>::iterator pos; //Vector iterator
     3:
     4: 	//Set the iterator to the first customer in the line
     5: 	pos = line[num].begin();
     6:
     7: 	//Get the first customer in the line, then erase it from
     8: 	// the vector
     9: 	Customer *c = line[num].at(pos);
    10: 	line[num].erase(pos);
    11:
    12: 	//If the line is not empty
    13: 	if (!line[num].empty()) {
    14: 		//Make sure the iterator is set to the first position
    15: 		pos = line[num].begin();
    16: 
    17: 		//Service the next customer in this line
    18: 		serviceCust(num, line[num].at(pos));
    19: 	}
    20: 	return c;
    21: }
    The errors occur on the following lines...
    Line 9: error C2664: 'class Customer *const &__thiscall std::vector<class Customer *,class std::allocator<class Customer *> >::at(unsigned int) const
    ' : cannot convert parameter 1 from 'class Customer ** ' to 'unsigned int'


    Line 18: error C2664: 'class Customer *const &__thiscall std::vector<class Customer *,class std::allocator<class Customer *> >::at(unsigned int) const
    ' : cannot convert parameter 1 from 'class Customer ** ' to 'unsigned int'


    Notes:

    line[ ] is declared as: vector<Customer*> line[2];
    It is the array of line queues for the store.

    serviceCust is a function that basically calculates the customers' departure times and schedules them. The prototype is: void serviceCust(int num, Customer *c);

    Do you know why I am getting these errors, and how I can fix them?

    The details of the code are probably irrelevant to the problem I am having, but if you need any more information regarding my program, please let me know.
    Thank you in advance for any help you can provide me.
    Last edited by waverdr9; April 6th, 2004 at 03:03 AM.

  2. #2
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720
    since 'at' takes the unisgned int, you cannot provide iterator as param for it, and iterator is 'Customer **' in this case, try:
    Code:
    Customer *c = line[num].at(0);
    //or
    Customer *c = line[num][0];

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured