P
P
Peter Tsinnikov2019-08-14 18:46:15
OOP
Peter Tsinnikov, 2019-08-14 18:46:15

Should the Bridge pattern look something like this?

Hello, I found an implementation of the bridge pattern on the Internet, it looks like this, but there is a question, is it correct?

class Implementor;

class Abstraction {
public:
    virtual ~Abstraction() {};
    virtual void Operation() = 0;
protected:
    Implementor* implement;
};

class RefinedAbstraction : public Abstraction {
public:
    void Operation() {
        //...код
    }
};

class Implementor {
public:
    virtual ~Implementor() {};
    virtual void OperationImp() = 0;
};

class ConcreteImplementor1 : public Implementor {
public:
    void OperationImp() {
        //...код
    }
};

class ConcreteImplementor2 {
public:
    void OperationImp() {
        //...код
    }
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Knatarev, 2019-08-14
@abudabibu

Yes, something like this, but usually RefinedAbstraction is not one (like yours), but several + you can preferably write code in implementations, otherwise it’s not clear why there are two identical classes, or instead of "//... code" write "// ...implementation1" and "//...implementation2" respectively.
Can someone correct me, and so the implementation is correct ideologically

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question