Reputation:
I am developing a Client-Server prototype with protocol Buffers. I have two main requirements to see how efficient Protocol Buffers is and the requirements are following.
Do you have any idea how c++ deals with Run-time changes ?
Upvotes: 1
Views: 90
Reputation: 30136
This answer contains only general guidelines, and I will probably get down-voted on it:
Use a linked-list (or any other data structure that can be used as FIFO), instead of an array.
Define a generic class called DataType, with a set of interface routines common to all your different data types.
For every data type you have, define a specific class which inherits from class DataType.
In each node in the linked list, store a pointer to a DataType instance; whenever you add a new entry, create a new instance of one of your data-type classes, and set the DataType pointer of the new entry to point to that instance.
Make sure that the destructor in class DataType is virtual, i.e., virtual ~DataType()
.
P.S.: the guidelines above are under the assumption that you have a finite number of different data types defined in advanced.
Upvotes: 0
Reputation: 993075
Do you have any idea how c++ deals with Run-time changes ?
It doesn't. C++ does not have any facility to change the definition of a struct
or class
at runtime.
However, depending on your needs, you can use existing C++ data structures such as std::map
to implement your own data container whose members can change at runtime.
Upvotes: 1