explicit
unless you know you want them to trigger implicit conversions.
Don't write:
class Foo
{
public:
Foo (int i);
private:
int i_;
};
Foo::Foo (int i)
{
i_ = i;
}
But instead write:
class Foo
{
public:
Foo (int i);
private:
int i_;
};
Foo::Foo (int i)
: i_ (i)
{
}
virtual if there is at least one
virtual method in your class
(see
When should my destructor be virtual?).
operator,, operator|| and
operator&&.
operator&.
friends to circumvent bad design.
new.
See
this FAQ.
throw because some compilers
(including some versions of gcc) will reject your code. Here is an
example of what should not be done:
int main ()
{
throw (Foo ());
}