G
Gary Wessle
Hi
the code below I wrote to mirror the problem I am having in my program,
please note the code below, I am expecting different Consumers in the
same Group to have the same Account information. but I am getting no
information on their joint account as it stands when I fire the method
c->consume() in class Grou_task below,
thanks for you help.
****************************************************************
class Consumer
{
Account* acc;
public:
Consumer(Account* acc){}
void consume();
};
****************************************************************
class Group
{
Account acc;
public:
vector<Consumer> cons_vec;
Group(vector<string> consumer_names)
{
group_them(consumer_names);
}
void group_them(vector<string> cn){
for(vector<string>::const_iterator i=cn.begin();
i!=cn.end(); i++){
Consumer con(&acc);
cons_vec.push_back(con);
}
}
};
****************************************************************
class Grou_task
{
vector<Group> group_vec;
void names2groups();
void operate();
public:
Grou_task()
{
names2groups();
}
void names2groups(){
/* Instantiate a group for each combination of consumers
and populate group_vec.*/
for( ... ) {
vector<string> combi;
for( int i=0; i<10 ;i++) // group of 10 consumers
combi.push_back( some_name_from_vector[k] );
Group group10( combi );
group_vec.push_back( group10 );
}
}
void operate(){
for( vector<Group>::iterator g = group_vec.begin();
g != group_vec.end(); i++ ){
for( vector<Consumer>::iterator c = (g->cons_vec).begin();
c != (g->cons_vec).end(); c++ ){
c->consume();
}
}
}
};
the code below I wrote to mirror the problem I am having in my program,
please note the code below, I am expecting different Consumers in the
same Group to have the same Account information. but I am getting no
information on their joint account as it stands when I fire the method
c->consume() in class Grou_task below,
thanks for you help.
****************************************************************
class Consumer
{
Account* acc;
public:
Consumer(Account* acc){}
void consume();
};
****************************************************************
class Group
{
Account acc;
public:
vector<Consumer> cons_vec;
Group(vector<string> consumer_names)
{
group_them(consumer_names);
}
void group_them(vector<string> cn){
for(vector<string>::const_iterator i=cn.begin();
i!=cn.end(); i++){
Consumer con(&acc);
cons_vec.push_back(con);
}
}
};
****************************************************************
class Grou_task
{
vector<Group> group_vec;
void names2groups();
void operate();
public:
Grou_task()
{
names2groups();
}
void names2groups(){
/* Instantiate a group for each combination of consumers
and populate group_vec.*/
for( ... ) {
vector<string> combi;
for( int i=0; i<10 ;i++) // group of 10 consumers
combi.push_back( some_name_from_vector[k] );
Group group10( combi );
group_vec.push_back( group10 );
}
}
void operate(){
for( vector<Group>::iterator g = group_vec.begin();
g != group_vec.end(); i++ ){
for( vector<Consumer>::iterator c = (g->cons_vec).begin();
c != (g->cons_vec).end(); c++ ){
c->consume();
}
}
}
};