# mco_get_class_code
RT

> Return the class code of the object referenced by an object handle.

### Prototype

        MCO_RET mco_get_class_code( /*IN*/ void * object_handle,
                        /*OUT*/ uint2 * code );

### Arguments

object_handle | The handle of a database object
code | The address of an unsigned 2 byte integer to receive the integer class code for this object

### Description

> This function returns the class code of the object referenced by the object handle. It can be called anytime the application needs to identify the class the object in hand belongs to.

### Return Codes

MCO_S_OK | The class code was successfully returned

### Example

        Application snippet:

        const char * dbname = "SimpleDb";

        int main(int argc, char* argv[])
        {
            mco_db_h db;
            MCO_RET rc;
            mco_device_t       dev;
            mco_db_params_t    db_params;
            mco_trans_h t;
            ...

            if( (rc = mco_runtime_start()) != MCO_S_OK)
                exit(-1);

            rc = mco_db_open_dev( dbname, simpledb_get_dictionary(), &dev, 1, &db_params );
            if ( MCO_S_OK != rc )
            {
                rc = mco_db_connect(  dbname, &db );
                ...
                // Instantiate an object of class A and get its class code
                rc = mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);
                if ( MCO_S_OK == rc ) {
                    A        a;   /* Object handle */
                    uint2 code;
                    rc = A_new ( t, &a );
                    rc = mco_trans_commit( t );

                    rc = mco_get_class_code( &a, &code );

                }
            }
        }

### Files

Header file:
mco.h
Source file:
mcowrap.c
Library:
libmcolib.a