Problem understanding glutMotionFunc

I am working on a simple paint program for my computer graphics class. I have experience using C++ but not openGL.

What I need my program to do is draw a rectangle on the screen and allow me to use the mouse cursor to “paint” using the rectangle. (this is similar to the paint program in Windows).

I need help learning how to implement the glutMotionFunc. I have used glutMouseFunc so when I click the mouse it will draw the square. Now I want to be able to draw multiple squares when I move the cursor. I will load/send my source code if needed.

thank you if you can help!