I have to write a class with a function which has a list<string>
named logstr
.
class write_logList_t : public text_log_i
{
private:
list<string> logstr;
public:
inline write_logList_t() : text_log_i() {}
inline virtual void write(const string_t& description) { logstr.push_back(description);} // It seems that it's not the right way to add a string to list of strings.
void printList();
};
extern write_logList_t write_logList;
write_logList_t write_logList;
void write_logList_t :: printList()
{
for (std::list<string>::iterator it=logstr.begin(); it != logstr.end(); ++it)
std::cout << ' ' << *it;
cout << endl;
}
int main()
{
counter_logs_t counter1;
write_logList_t write1;
enum { A, B, C };
const char* names[] = { "a", "b", "c" };
state_machine_t sm("3state", 3, A, names);
/*sm.add_log((log_i*)new cout_log_t());*/
sm.add_log((log_i*) &counter1);
sm.add_log((log_i*)new write_logList_t());
sm.goto_state(A);
sm.goto_state(B);
sm.goto_state(C);
counter1.print_counter();
write1.printList();
return 0;
}
For some reason the logstr
member is not recognized. When I debug the code and put logstr
in watch I can see that it doesn't get any value, instead there is a comment which says:
Couldn't find method std::list, std::allocator >, std::allocator, std::allocator > > >::c_str
Aucun commentaire:
Enregistrer un commentaire