All Questions

1719
votes
8answers
202379 views

What is The Rule of Three?

What does copying an object mean? What are the copy constructor and the copy assignment operator? When do I need to declare them myself? How can I prevent my objects from being copied?
294
votes
8answers
52577 views

Rule-of-Three becomes Rule-of-Five with C++11?

So, after watching this wonderful lecture on rvalue references, I thought that every class would benefit of such a "move constructor", template<class T> MyClass(T&& other) edit and of co...
3
votes
3answers
925 views

Rule of Three in C++

I've read that The Rule of Three, What is The Rule of Three? is summarized as follows: If you need to explicitly declare either the destructor, copy constructor or copy assignment operator...
16
votes
3answers
787 views

Exception to the Rule of Three?

I've read a lot about the C++ Rule of Three. Many people swear by it. But when the rule is stated, it almost always includes a word like "usually," "likely," or "probably," indicating that there are e...
8
votes
5answers
13717 views

C++ Copy Constructor + Pointer Object

I'm trying to learn "big three" in C++.. I managed to do very simple program for "big three".. but I'm not sure how to use the object pointer.. The following is my first attempt. I have a doubt when...
8
votes
2answers
10610 views

Understanding -Weffc++

Consider the following program: #include <string> struct S { S (){} private: void *ptr = nullptr; std::string str = ""; }; int main(){} This, when compiled with -Weffc++ on GCC...
4
votes
2answers
380 views

Are there any static analysis tools that check for Rule of 3 (or Rule of 5 C++11)

I am currently working on a codebase that is built on a foundation of sand. There are numerous classes in supposedly tested libraries that violate the "Rule of 3". Most declare a non-trivial destruc...

Previous Next