What does "delete" do in front of the constructor?

Asked

Viewed 92 times

4

What does that mean delete in front of the builder?

Grap& operator=(const Grab &g) = delete;

1 answer

2


Note that this is an assignment operator and not a constructor.

It is invalidating this operation. Every type in C++ has the assignment operator automatically created by the compiler if none is provided. When your type cannot allow assignments to be done with it, this is the way to prevent the compiler from creating the operator for you.

You can do the same with the copy operator.

Only available from C++11.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.