T
thomas
Hi guys,
------------------------------------------------------------------
struct Item{
int i;
};
class Child(){
void dosth(){
for (int i = 0; i < 100; ++i)
{
Item* newItem = new Item();
Parent.push(newItem); //A
}
}
}
class Parent{
public:
void push(Item* p){
VecItem.push_back(p);
}
vector<Item*> VecItem;
Child* pChild;
};
-----------------------------------------------------------------
How to modify line A to make it work correctly and elegantly?
1. I don't want to pass vectors between classes
2. I infer if something like allocator can make it work.
3. I don't want to expose the whole class Parent to Child, because
there are many other interfaces that Child doesn't need.
------------------------------------------------------------------
struct Item{
int i;
};
class Child(){
void dosth(){
for (int i = 0; i < 100; ++i)
{
Item* newItem = new Item();
Parent.push(newItem); //A
}
}
}
class Parent{
public:
void push(Item* p){
VecItem.push_back(p);
}
vector<Item*> VecItem;
Child* pChild;
};
-----------------------------------------------------------------
How to modify line A to make it work correctly and elegantly?
1. I don't want to pass vectors between classes
2. I infer if something like allocator can make it work.
3. I don't want to expose the whole class Parent to Child, because
there are many other interfaces that Child doesn't need.