Classes are derived datatypes.
When you want to create your own datatype, with its own methods/functions for working with it, then one should implement classes.
Example : Suppose you are given a code to create a student dataype and record there information, this is a basic code while implementing class.
char add ;
cout<<"\n enter the student roll no.";
cout<<"\n enter the student name";
cout<<"\n enter ther student address";
cout<<"\n enter the student city";
cout<,"\n the student roll no:"<<roll;
cout<<"\n the student name:"<<name;
cout<<"\n the student coty:"<<city;
As shown by np_complete, you can implement methods of a class inline, in which case you don't need to compile them as a separate translation unit. They are truly inline code, implemented in each translation unit that uses them.