samedi 1 décembre 2018

How do I define an iterator for a class that only contains an carray of ints in c++?

I have a class that looks like this:

class Image {
public:
    int * pixels;
    class iterator {
        //help here
    }
    begin(){}
    end(){}

    ///other code to manipulate those pixels
}

All I have to do is make it so that Image::begin() and Image::end() functions return the corresponding object of type Image::iterator. I understand that this a silly thing to do when I could just use a normal int array iterator but its for a project and the return type is part of the requirement. I have no need to change any other functionality.

Aucun commentaire:

Enregistrer un commentaire