+ 6

Something Witty But Purely Logical This Time

How can you stop objects from being copied. Objects are copied when we pass them through call by value method, return an object, or ob1=ob2. So I want you to figure out how you can stop from objects being copied.

12th Nov 2016, 4:07 PM
Megatron
Megatron - avatar
3 Answers
+ 2
Well don't take it as a question Take it up as a challenge. I do not want to deal with original objects but. I want that if any object is being copied in program anywhere it should produce error or stop compilation. That is if I insert that part of code in some other program and if that program is copying objects anywhere in the program an error should be reported by compiler.
12th Nov 2016, 4:32 PM
Megatron
Megatron - avatar
0
pass it as reference i.e put &before the object name in the parameter list. but the function must accept it as a pointer
12th Nov 2016, 4:57 PM
Fayeed Pawaskar
Fayeed Pawaskar - avatar
0
Define a private copy constructor and assignment operator would do the trick i believe...
26th Dec 2016, 8:07 PM
ifl
ifl - avatar