P
Puvendran
Hi,
I am trying to create an array of pointers to a vector which holds
values of a user defined class. The application involved needs
multiple arrays to point the same vector ie
class message
{
public:
string from;
};
void main()
{
vector<message>* Arr1[10];
vector<message>* Arr2[10];
message m1;
m1.from = "john";
Arr1[0].push_back(&m1);
)
I get the following compilation error due to the last line
test1.cc:45: request for member `push_back' in `n[0]', which is of
non-aggregate
type `vector<message,allocator<message> > *'
What I am trying to achieve in my application is for objects of type
message to be shared,via pointers, thereby saving memory, rather than
each array having identical copies of the same object.
So, what I need is
1. To be able to add message object to Arr1
2. Subset of the messages in Arr1 to be referenced by Arr2
3. Display the contents of Arr1/Arr2.
Thanking you in advance
Puvendran
I am trying to create an array of pointers to a vector which holds
values of a user defined class. The application involved needs
multiple arrays to point the same vector ie
class message
{
public:
string from;
};
void main()
{
vector<message>* Arr1[10];
vector<message>* Arr2[10];
message m1;
m1.from = "john";
Arr1[0].push_back(&m1);
)
I get the following compilation error due to the last line
test1.cc:45: request for member `push_back' in `n[0]', which is of
non-aggregate
type `vector<message,allocator<message> > *'
What I am trying to achieve in my application is for objects of type
message to be shared,via pointers, thereby saving memory, rather than
each array having identical copies of the same object.
So, what I need is
1. To be able to add message object to Arr1
2. Subset of the messages in Arr1 to be referenced by Arr2
3. Display the contents of Arr1/Arr2.
Thanking you in advance
Puvendran