A class diagram describes the structure of a system by showing classes, attributes, operations, and relationships among classes. A class represents a set of objects that share attributes, operations, and semantics. It is drawn as a rectangle with the class name, attributes, and operations in compartments. Relationships include dependencies, generalizations, and associations. Generalization connects a subclass to a superclass, allowing encapsulation and specialization. Associations link communicating classes, with multiplicity indicating the number of instances in the relationship.