In most cases, your professor will make it clear what work is intended to be done individually. Discussing class material with a classmate can often be a helpful practice and can help clarify concepts and bring to light new ideas; however, assignments and essays should be done individually. Your professor may consider your work cheating if work is strikingly similar,

If you are in doubt about whether or not it is acceptable to collaborate with a classmate, ask your professor.