

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is The Rule of Three with reference to C++?
The Rule of three is a rule of thumb when using C++. This is kind of a good practice rule that says that If your class needs any of
- a copy constructor,
- an assignment operator,
- or a destructor,
defined explicitly, then it is likely to need all three of them.
Why is this? Its because, if your class requires any of the above, it is managing dynamically allocated resources and would likely be needing the other to successfully achieve that. For example, if you require an assignment operator, you would be creating copies of objects currently being copied by reference, hence allocating resources. You'll need the copy constructor for copying and destructor for freeing up these resources.
- Related Questions & Answers
- C++ Rule Of Three.
- Rule of Three vs Rule of Five in C++?
- Rule Of Three in C++
- What is the locality of reference?
- What is the working of Association Rule?
- What is the OSI Reference Model?
- What is Association rule learning?
- What is the three layer of IOT architecture?
- What is Rule of Five in C++11?
- What is the golden rule for complimentary feeding?
- What is the TCP/IP Reference Model?
- What are the applications of Association Rule?
- What is horizontal rule in HTML Page?
- What is Three Address Code?
- What is the Kenney Rule, and how does it work?
Advertisements