CaseyJones
Banned User
- Joined
- Jul 29, 2016
- Messages
- 4
- Reaction score
- 1
Can anyone explain to me the purpose of this fragment of code I am really having trouble wrapping my head around it.
I have a general idea of what is going on here Player is a constructor its argument is a reference to a Player object the overloaded constructor of Player is an assignment with also an argument of a reference to Player which is assigned delete to prevent a default constructor being called.
If I am wrong about its ok as I said I am having a tough time wrapping my head around this. Any help on this matter will be greatly appreciated.
Correction the overloaded constructor of Player has an overloaded assignment operator which is passed a reference of type Player, yes both arguments in each constructor are const's.
One more thing I would like to note there is no definition of the overloaded operator for the constructor defined in player.cpp maybe this is what is throwing me off?
I guess it doesn't need to be defined? As delete is destroying the constructor... this is really frustrating trying to understand.
bump
Code:
// non-copyable
Player(const Player&) = delete;
Player& operator=(const Player&) = delete;
I have a general idea of what is going on here Player is a constructor its argument is a reference to a Player object the overloaded constructor of Player is an assignment with also an argument of a reference to Player which is assigned delete to prevent a default constructor being called.
If I am wrong about its ok as I said I am having a tough time wrapping my head around this. Any help on this matter will be greatly appreciated.
Correction the overloaded constructor of Player has an overloaded assignment operator which is passed a reference of type Player, yes both arguments in each constructor are const's.
One more thing I would like to note there is no definition of the overloaded operator for the constructor defined in player.cpp maybe this is what is throwing me off?
I guess it doesn't need to be defined? As delete is destroying the constructor... this is really frustrating trying to understand.
bump
Last edited by a moderator: