In C++ protobuf, each message owns its fields. That said, two different
messages cannot share a sub-message, which will complicate the system when
releasing resources.
In your case, if you always need to copy the records, there may be a better
design. For instance, keep the records in a global
hello:
we defined two object in field.proto
message Record{
optional int id = 1;
}
message RecordSet{
repeated Record record= 1;
}
so when we define a Record pointer,we do like this:
RecordSet recordsetA,recordsetB;
Recrod *pRecordA = recordsetA.add_record();
pRecordA-set_id(111);
actually