RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Blocking Undesirable Object Copying and Implicit Conversions

C++ doesn't offer a direct mechanism for blocking undesirable copying or preventing implicit conversion of arguments. However, with some code tweaks you can work around these problems.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

ingletons, stream objects, and other classes must disable copying and assignment. However, C++ doesn't yet provide a direct mechanism for disabling copying. Another related problem exists with undesirable conversions of arguments passed to a function. The following sections will show how to work around these limitations to block undesirable copying and assignments and prevent implicit conversions of arguments.

There's no means to suppress the compiler's automatic declaration of a copy constructor and an assignment operator—even if you wish to disable copying and assignment of certain objects. Likewise, you cannot instruct the compiler to disable automatic conversions of arguments passed to a function.

Declare the copy constructor and assignment operator explicitly as private members without defining them. To prevent undesirable implicit conversions of arguments, declare dummy signatures that intercept the wrong types of arguments.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date