防止编译器为C ++类定义复制构造函数和operator = overload [英] Preventing compilers from defining copy constructors and operator = overload for C++ Classes

查看:210
本文介绍了防止编译器为C ++类定义复制构造函数和operator = overload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法可以阻止编译器定义复制构造函数,C ++类的operator = overload。

Is there a way by which we can prevent compilers from defining copy constructors, operator = overload for C++ classes.

推荐答案

您可以将这些函数声明为私有的,以防止人们在使用类时使用它们,同时防止编译器生成它们。

You can declare these functions as private which prevents people from using them when working with your class and at the same time prevents the compiler from generating them.

这篇关于防止编译器为C ++类定义复制构造函数和operator = overload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆