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.

class student 
    int roll;
    char name[25];
    char add [25];
    char city[90];


    void getdata()
        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";
    void putdata()
        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.

This question has already been answered. Start a new discussion instead.