← Back to team overview

dolfin team mailing list archive

Re: Use of explicit

 

Without it, the constructor may be automatically transformed to an
operator= for the same type. Take for example this code:

class A
{
public:
  A(int N) { x = new real[N]; }
  ~A() { delete [] x; }
};

A a(100);
a = 200; // legal without explicit above

which will lead to disaster.

-- 
Martin


2008/4/29  <kent-and@xxxxxxxxx>:
> > All constructors with a single argument.
>  >
>  > --
>  > Martin
>  >
>  >
>
>  Why ? What does it mean ?
>
>  Kent
>
>


Follow ups

References