I'm new to C++ (math major here). Here's a simple example of what I'm trying to do.
Suppose I have some struct, we'll call it simple.
Now, suppose I have another struct that contains some data, and an std::list that will hold type simple:Code:typedef struct simple { int a; }simple;
Now, in main, if I want to create a type of tx_info, and use that list, I'm not sure what theCode:typedef struct _tx_info { int something; list<simple*> simple_list; }tx_info;
syntax is just to instantiate the list..
Obviously, this will segfault because I never instantiate the list.Code:int main(int argc, char ** argv) { tx_info * info = (tx_info*)malloc(sizeof(tx_info)); simple * s = (simple*)malloc(sizeof(simple)); s->a = 10; info->simple_list.push_front(s); return 0; }
What's confusing to me, is if at the top of the C++ file, I do
that will both declare and instantiate a list. I'm not sure how to instantiate it when my list isCode:list<simple*> simple_list;
declared within a struct.
Thanks so much for the help!



LinkBack URL
About LinkBacks



