Doubt about functions and classes

0
class base_token
{

    public:

        typedef enum {  t_invalid_token=0, t_symbol, t_integer, t_literal,

                        t_punctuation, t_keyword

                     } type_of_token;

    private:

        type_of_token token_type;

    public:

        base_token(type_of_token token) : token_type(token) { };

        type_of_token get_type() { return token_type; };

        virtual const char *  parse_token(const char * s) = 0;

};

This line is telling you what (syntax)?

base_token(type_of_token token) : token_type(token) { };
    
asked by anonymous 04.10.2015 / 23:59

1 answer

0

I'll give you an answer thinking from the semantic point of view, I believe this is the purpose of your question. If it is not, I edit it and put the parsing.

This line declares a constructor for the base_token class. Constructors are methods that have the same class name, do not return any type (not even void ).

This constructor requires a single parameter, of type type_of_token . The parameter name is token .

The constructor initializes the token_type (declared with access private ) field with the value passed in the token argument.

The body of the method is empty.

This constructor (in these specific conditions), is equivalent to:

base_token(type_of_token token) {
    token_type = token;
}

Both in the context of the class displayed, have the same effect.

Note that this is a C ++ question, not C.

    
05.10.2015 / 01:50