Understanding Code/Class definition

Hi, I'm trying to understand how the following declaration works.
First class name1::name2{}, how do I interpret that. Second the first public member is just a function HAL() with no type definition.third there is a ":" after HAL() which makes me think inheritance. Fourth there are some more public declarations name1::type some_ptr. All this looks very different then the standard C++ class declaration I'm used from my college book. Could somebody please walk me through this code and explain what each line does and how are the members,variables and functions related.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class AP_HAL::HAL {
public:
    HAL(AP_HAL::UARTDriver* _uartA,
        AP_HAL::UARTDriver* _uartB,
        AP_HAL::UARTDriver* _uartC,)
        :
        uartA(_uartA),
        uartB(_uartB),
        uartC(_uartC),
    {
    //nothing here
    }

    virtual void init(int argc, char * const argv[]) const = 0;

    AP_HAL::UARTDriver* uartA;
    AP_HAL::UARTDriver* uartB;
    AP_HAL::UARTDriver* uartC;

};
Last edited on
class name1::name2{}, how do I interpret that
It is a qualified name of class. It either in namespace AP_HAL or a subclass of class AP_HAL
the first public member is just a function HAL() with no type definition
It is a constructor
http://www.learncpp.com/cpp-tutorial/85-constructors/
there is a ":" after HAL() which makes me think inheritance
It is a constructor initializer list
http://www.learncpp.com/cpp-tutorial/101-constructor-initialization-lists/
there are some more public declarations name1::type some_ptr
They are defined in AP_HAL namespace or class
All this looks very different then the standard C++ class declaration I'm used from my college book
All of these features are pretty old.

Last edited on
Topic archived. No new replies allowed.