According to the C++ Primer book, "The arrow operator requires a pointer operand and yields an lvalue". Is that always the case? For example:
#include<iostream>
#include<string>
using std::string; using std::vector;
int main()
{
vector<string> temp {"aaa", "bbb", "ccc"};
vector<string>::iterator iter_str = temp.begin();
bool result = iter_str->empty(); //the result of iter_str->empty() is not an lvalue right?
return 0;
}
- When we take the expression iter_str->empty() for instance it can't be the left hand operand of an assignment operator right?
- And if the arrow operator returns an lvalue does it not have to, at all times? Or are there exceptions to this rule?
Aucun commentaire:
Enregistrer un commentaire