Ok so I'm working on an assignment that prompts the user for a number of rooms and then asks the user for the length and width of each room. When I compile, I get "expected unqualified-id before [ token" on lines 36, 37, 40, 41 Here is the test code I'm working with. Any help would be appreciated.
wow I haven't seen auto used like that in forever.
Just so you know, you don't have to type auto in those cases. It's implied. It's actually kind of weird of you to be using it.
anyway your problem is this:
CRoom[numRooms].GetLength(len);
CRoom is a class, but you're [indexing] it like it were a pointer/array.
You probably meant to do this:
rooms[index].GetLength(len);
Note you should index 'rooms' (your array) not CRoom (the class name)
also note you should use 'index' to index it and not 'numRooms' as numRooms will cause you to go out of bounds of your array.
test.cpp:36: error: no matching function for call to âCRoom::GetLength(int&)â
test.cpp:9: note: candidates are: int CRoom::GetLength()
test.cpp:37: error: no matching function for call to âCRoom::SetLength()â
test.cpp:11: note: candidates are: void CRoom::SetLength(int)
test.cpp:40: error: no matching function for call to âCRoom::GetWidth(int&)â
test.cpp:10: note: candidates are: int CRoom::GetWidth()
test.cpp:41: error: no matching function for call to âCRoom::SetWidth()â
test.cpp:12: note: candidates are: void CRoom::SetWidth(int)
Also I know that 'auto' is deprecated, its how out teacher taught us. I need more than two hands to count the number of times people have commented on that haha.
int whatever = rooms[index].GetLength();
// 'whatever' now holds the length of the room
//=====
rooms[index].SetLength( some_new_length );
// this changes the length of the room to 'some_new_length'