What language are you talking about? In Java or C# that's not true. Functions are local and can only be called within the function itself unless they're returned to the calling function.
Classes are templates, which the variables are either local, or global.
A function is a subroutine, a class is a template for an object...kind ofo like a blue print.