An opportunity cost is a foregone benefit that would have been derived via an option not taken. To invest money in one stock is to not invest that money in another. If the chosen stock accrues a 20% increase, but an alternative accrues a 30% increase, the opportunity cost is the 10% profit not earned on the money invested.
In real life, these costs are rarely so obvious. For example, at Steve’s current job at GadgetsPlus, he earns £50k a year with little projected career growth. He is offered a job at InfiniteTech starting at £45k for the first year, promising career progression. By accepting the job, he incurs a £5k opportunity cost for the first year. In the second year, he might receive a £15k raise - from there, the opportunity cost of his previous job at GadgetsPlus would be £10k. In evaluating whether or not to take the job at InfiniteTech, he probably isn’t aware that this would happen in the second year and may well stay at GadgetsPlus.
These are effectively hidden costs because they are the costs of paths not taken. Therefore, they do not declare themselves. In evaluating options, we have to do the extra work of being mindful of which benefits we miss when we select one choice over another.