It is usually made of netting or a chain-link fence and rectangular in shape. A batter stands at one end of the cage, with a pitching machine (or less often a live pitcher) at the opposing end. The pitcher or pitching machine pitches baseballs to the batter, who hits them.
The cage is used to keep the baseballs within a certain range so that they're easy to pick up and are not lost. Batting cages are often found indoors, or where space is limited.
The interior floor of a batting cage may be sloped, to automatically feed the baseballs back into the automatic pitching machine. The automatic pitching machines using sloped floors usually pitch out a synthetic baseball or softball, rather than an official leather-clad ball.
Commercial batting cages pitch with several different speeds, which can range from 30 (generally softball) to 90 miles per hour.
Cricket nets, used by cricket batsmen are similar in purpose, but bowling machines are much less common than facing a live bowler (this reflects the fact that nearly half of the members of a cricket team are specialist bowlers, and therefore proportionately more bowling practice is needed in cricket than pitching practice in baseball).