I am searching a std::string for certain letters so I am using:
for (int i = 0; i < word.length; i++)
...
But I then get the error:
Error 2 error C3867: ‘std::basic_string<_Elem,_Traits,_Alloc>::length’: function call missing argument list; use ‘&std::basic_string<_Elem,_Traits,_Alloc>::length’ to create a pointer to member
So I put:
for (int i = 0; i < &word.length; i++)
...
And then get the error:
Error 2 error C2276: ‘&’ : illegal operation on bound member function expression
How can I fix this and search the string? Thanks in advance.
You’re just missing the
()afterlength.std::string::length()is a function which has no parameters.