void for_all(C& c, Oper op) // assume ."/> void for_all(C& c, Oper op) // assume ."/> void for_all(C& c, Oper op) // assume "/>
خرید بک لینک

Vote count: 0

I'm reading "The C++ Programming Language (4th edition)" and I ran into this:

template<class C, class Oper>
void for_all(C& c, Oper op) // assume that C is a container of pointers
{
    for (auto& x : c)
    op(∗x); // pass op() a reference to each element pointed to
}

So from what I understand, we're iterating through c and getting a reference to x, which is the current iteration. x is then passed to the function call operator of op, but it is dereferenced first? Why would x be dereferenced?

asked 31 secs ago

- - , .
.

برچسب: نویسنده: استخدام کار تاريخ: جمعه 25 تير 1395 ساعت: 12:07

صفحه بندی