The first one is better
Even better is C++0x ‘delete’ keyword:
class Class {
// useful stuff, then
public:
Class(const Class&) = delete;
void operator=(const Class&) = delete;
};
More Related Contents:
- Why should the copy constructor accept its parameter by reference in C++?
- What is a converting constructor in C++ ? What is it for?
- Why copy constructor is not called in this case?
- no default constructor exists for class
- The copy constructor and assignment operator
- constructor invocation mechanism
- Why aren’t copy constructors “chained” like default constructors and destructors?
- C++ copy-construct construct-and-assign question
- Default constructor with empty brackets
- What are the rules for calling the base class constructor?
- Conditions for automatic generation of default/copy/move ctor and copy/move assignment operator?
- Why must the copy assignment operator return a reference/const reference?
- Throwing exceptions from constructors
- A most vexing parse error: constructor with no arguments
- Is passing a C++ object into its own constructor legal?
- What is a non-trivial constructor in C++?
- What is an in-place constructor in C++? [duplicate]
- Why is protected constructor raising an error this this code?
- Copy constructor is not inherited
- C++: Construction and initialization order guarantees
- Is a `=default` move constructor equivalent to a member-wise move constructor?
- Forwarding all constructors in C++0x
- Different ways of initializing an object in c++
- Calling assignment operator in copy constructor
- Class inherited from class without default constructor
- Conflict between copy constructor and forwarding constructor
- Uniform initialization fails to copy when object has no data members
- Using C++ base class constructors?
- C++ Member Initializer List
- How can I initialize C++ class data members in the constructor?