Horje
prevent copy c++ Code Example
prevent copy c++
Method 1: Private copy constructor and copy assignment operator
  class Car {
public:
  Car(): owner() {}
  void setOwner(Person *o) { owner = o; }
  Person *getOwner() const { return owner; }
  void info() const;
private:
  Car(const Car&);
  Car& operator=(const Car&);
  Person *owner;
};

Method 2: Deleted copy constructor and copy assignment operator
  class Car {
public:
  Car(const Car&) = delete;
  void operator=(const Car&) = delete;
  Car(): owner() {}
  void setOwner(Person *o) { owner = o; }
  Person *getOwner() const { return owner; }
private:
  Person *owner;
};




Cpp

Related
UPARAM(ref) Code Example UPARAM(ref) Code Example
stringstream stream number to string Code Example stringstream stream number to string Code Example
ue4 c++ replicate actor variable Code Example ue4 c++ replicate actor variable Code Example
detect end of user input cpp Code Example detect end of user input cpp Code Example
ascii allowed in c++ Code Example ascii allowed in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8