An object-oriented programming approach for computer simulations in magnetic resonance is described. By the definition of new data types, such as operators, superoperators, and tensors, a powerful programming environment is created that facilitates computer simulations for a wide variety of situations covering multiple-pulse experiments in liquids and solids for NMR, NQR. and EPR. A new magnetic resonance toolkit GAMMA, based on the computer language C++, is exemplified by simulations of liquid-state and solid-state NMR experiments. © 1994 by Academic Press, Inc.