We consider variants of the classic bin packing and multiple knapsack problems, in which sets of items of {\em different classes (colors)} need to be placed in bins; the items may have different sizes and values. Each bin has a limited capacity, and a bound on the number of distinct classes of items it can accommodate. In the {\em class-constrained multiple knapsack (CCMK)} problem, our goal is to maximize the total value of packed items, whereas in the {\em class-constrained bin-packing (CCBP)}, we seek to minimize the number of (identical) bins, needed for packing all the items. We give a {\em polynomial time approximation scheme} (PTAS) for CCMK and a dual PTAS for CCBP. We also show that the 0-1 class-constrained knapsack admits a {\em fully} polynomial time approximation scheme, even when the number of distinct colors of items depends on the input size. Finally, we introduce the {\em generalized class-constrained packing problem} ({\em GCCP}), where each item may have more than one color. We show that GCCP is APX-hard, already for the case of a single knapsack, where all items have the same size and the same value. Our optimization problems have several important applications, including storage management for multimedia systems, production planning, and multiprocessor scheduling.