I am trying to make a basic small program for school that takes a structure of a classroom and allows the user to create/edit a new classroom using the struct. The instructions for this assignment say to just create a function that will allow you to add data to the attributes of the classroom. Which i have done and tested and it works. Create a function that allows you to print out the classroom information. I have a function prototyped for that step and don't feel i'll need help doing that part. Then compare two classrooms based on the size (number of chairs) and report which classroom is larger. Also compare two classrooms base on utilization. I haven't gotten that far or tried to code that part yet but I figure I list the full assignment so you know what I am trying to accomplish.
The problem I am having has to do with my for loop inside the edit function. When trying to set my iterator to be the same size as my vector using "vector.max_size" I get a compile error well several but all linked to the same thing. Basically I want to list all the created classes by pulling the className string from the vector and have the user choose which class they want to edit.
error
1 2 3 4 5 6 7
error C3867: 'std::vector<classroom,std::allocator<_Ty>>::max_size': function
call missing argument list; use '&std::vector<classroom,std::allocator<_Ty>>::max_size'
to create a pointer to member
1> with
1> [
1> _Ty=classroom
1> ]
My guess is that some how there is a way to set the vectors size or allocate it in a way that will not throw the error? I think it might also be linked to how my add function is set up. Using "storedClass.push_back(classroom());" to allocate the first position in the vector so that I can add the newclassroom struct and edit using vector[0].className; etc.
Can some one please point me in the right direction on how I should be going about solving this issue or maybe let me know if there is a better way to do this? I know i need to use the vector for the comparison step later on.
Line 126: max_size is a function. You need () to call the function. You probably want size(), not max_size(). size() tells you how many entries are currently in the vector. max_size() tells you how many entries the vector can hold without reallocating storage. These are not the same thing.