[Solved] Having issue understand what does this constructor do


Firstly…

    typedef enum {
        Stop, Continue, Skip,
        LastRetType
    } 
    RetType;

…is a poor way of saying…

    enum RetType {
        Stop, Continue, Skip,
        LastRetType
    };

…which simply creates an enum type that can take on the listed values (Stop defaults to 0, Continue to 1 etc..).

The pre function…

    virtual RetType pre(PDTAdd & d) { 
        return Continue;
    }

…then returns any of these values – above it hardcodes Continue.

It is virtual though, which means a derived class can write its own override of the function, and if someone has a Traversal* p or Traversal& r that actually refers to an instance of such a derived class, it will be the most-derived class that provides an override (if any) whose function is run by p->pre(d) or r.pre(d). This is known as virtual dispatch, and is the way C++ supports runtime polymorphism, which is one of the fundamental functionalities for Object Oriented programming.

Your next move should be a good book or tutorial.

2

solved Having issue understand what does this constructor do