Class definitions are normally put in header files, which are included in the *.cpp file. This is done do that the class can be used anywhere within the program, not just main(). Right now you are probably writing very simple programs that contain only a main() function. What would you do with a program that has hundreds or even thousands of functions? You can't (or don't want to) define the same class over, and over for hundreds of times at the beginning of each function that needs it.