C++ Reference of vector
- by void
Hello,
class Refvect
{
public:
vector<int> &refv;
Refvect(int t, vector<int> &refv = vector<int>()) : refv(refv) { };
void operator()()
{
refv.clear();
}
};
int main ()
{
Refvect r(0);
r();
}
With Visual Studio 2010, this gives me an error : "vector iterators incompatible" at the execution, but I don't understand why (but I can insert elements in refv without any problem).
The temporary object vector() lives as long as the reference, no?