You need lines 161 to 165 of chainparams.cpp for mainnet, and lines 220 to 224 for testnet.

Here's the mainnet source:

base58Prefixes[PUBKEY_ADDRESS] = list_of(0);

base58Prefixes[SCRIPT_ADDRESS] = list_of(5);

base58Prefixes[SECRET_KEY] = list_of(128);

base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E);

base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4);

and here's the testnet source:

base58Prefixes[PUBKEY_ADDRESS] = list_of(111);

base58Prefixes[SCRIPT_ADDRESS] = list_of(196);

base58Prefixes[SECRET_KEY] = list_of(239);

base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);

base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);

In both blocks, the first line is the pay-to-pubkey prefix byte, the second is the pay-to-script-hash prefix byte, the third is the secret-key prefix byte. The fourth is a sequence of four bytes that prefixes deterministic-wallet public keys (so called "stealth addresses", as well as special keys that allow someone to accept but not spend payments &c. ) and the fifth is a sequence of four bytes used to prefix the corresponding deterministic-wallet secret keys.

Because the the prefix bytes are attached to a base256 encoding (ie, binary) of known width, they affect the leading cinquantoctal digit of the corresponding base58 representation of the same number. That zero is why mainnet pay-to-pubkey txouts always start with 1, the 5 is why mainnet pay-to-script-hash txouts always start with 3, and so on.

Incidentally, the four-byte prefixes correspond to cinquantoctal prefixes 'xpub' and 'xprv' on mainnet and 'tpub' and 'tprv' on testnet. Somebody with far too much time to invest in encoding transformations figured out what range of numeric values would start with 'xpub' and 'xpriv' etc when converted to base58 from a binary number 4 bytes wider than a key value, then exactly which four bytes to prefix to ensure that the base256 representation always yields a number in that range.