The salary cap is a numerical figure set by the league. Each team can make trades for players or sign players to contracts freely as long as the team total of salaries is below the salary cap.
For teams above the salary cap, players can only be signed or traded for if the team uses an exception - there are several of them.
If a team is far enough above the salary cap, it must pay a tax at the end of the year - this is commonly known as the luxury tax.
Here's a link to a big document written by Larry Coon.. It's the best source of information on the salary cap around.