can any anyone please tell me the difference between the .at() function and the [] operator in vectors.
Are they only different in context of the error generated by them?
operator[] does not do range checking. Accessing element not presenting in vector silently leads to undefined behavior. .at() member function does range checking and throws an exception when you are trying to access nonexisting element.
Compilers often allow range checking for operator[] too but it has to be turned on. It can be useful because you can do range checking while developing your program to find errors more easily but in the final program you can turn it off to avoid the overhead.