I have a class that should call a visitor method for every member variable. Something like this:

```
class A{
    int a, b, c;

public:
    void accept(Visitor &visitor){
        visitor.visit(a);
        visitor.visit(b);
        visitor.visit(c);
    }
};

```

How can I get `void accept() const` method with the same code without code duplication? 

The obvious solution with the duplication is to add a method:

```
void accept(Visitor &visitor) const {
    visitor.visit(a);
    visitor.visit(b);
    visitor.visit(c);
}

```

That method has exactly the meaning I want, but I would like to avoid the code duplication. The reason to have both methods is to be able to read the variables by a 'reading' visitor and having the `accept` method nicely `const`. Then the non-const `accept` would be possible to use for 'writing/updating' visitors.