uchar* ptr = (uchar*) (img->imageData + y * img->widthStep); 

Namely: = (type*) (...);

    1 answer 1

    Cast to type pointer to type . In the old, c-shny style.

    • and in the new plus how? - Grundy
    • @Grundy: static_cast or dynamic_cast , for example - VladD
    • @VladD in this case, rather reinterpret_cast . - αλεχολυτ
    • @Grundy Depends on what is required . In the most general case, this is reinterpret_cast . But this suggests that the types are completely incompatible. Ideally, if static_cast enough. const_cast and dynamic_cast too specific; Of course, this ghost may replace them - but at the same time, everything becomes completely unsafe ... - Harry
    • @alexolut: As far as I understand (there’s a necessary piece at the end of the answer), this is their mixture. (Or here .) - VladD