Subject: Definitions of interface classes

From: Alexandros Frantzis <[email-masked]>
Date: Tue, 26 Mar 2013 12:00:54 +0200

Hi all,

in the code we use a couple of slightly different ways to define
interface classes.  Although the variations are mostly equivalent
functionally, it would be nice to decide on a standard way and add
it to the coding guide. The variation I see mostly (and use) is:

class Interface
{
public:
    virtual ~Interface() {}

    virtual void method1() = 0;
    virtual void method2() = 0;

protected:
    Interface() = default;
    Interface(Interface const&) = delete;
    Interface& operator=(Interface const&) = delete;
};

There was also some discussion about using:

virtual ~Interface() = default;

because of the noexcept guarantee.

Thoughts?

Thanks,
Alexandros

---

From: Alan Griffiths <[email-masked]>
Date: Tue, 26 Mar 2013 11:13:03 +0000

> virtual ~Interface() = default;

This is my preference

> because of the noexcept guarantee.

This is why.
> Thoughts?

It does mean that derived classes (including mocks) need a "noexcept"
destructor. That can cause a cascade of changes and means mocks need an
explict noexcept destructor.