I have a class class1
with its a constructor class1(int i)
and a copy constructor class1(const class1& other)
.
Instances of class1
are created dynamically, since the int
argument is not known at compile time.
My problem is that I have to pass this pointer between a producer object and a consumer object:
void producer::produceAndSend(...) {
class1 *c1 = generate(...);
consumerObj.set(c1);
}
class consumer {
class1 *internalC;
void set(class1 *c);
}
void consumer::set(class1 *c) {
this->internalC = c; //This only copies the pointer, not the content
}
I would like to store a copy of the object pointed by c1
and this copy must be pointed by internalC
.
How can I achieve this?