|
|
> const Tree& build_tree(std::vector<SymbolInfo> info)
> {
> std::vector<Tree> trees;
>
...
>
> return trees[0];
> }
You are returning a reference to a local variable. When the function
finishes, trees' destructor will be called and all of its contents will be
deallocated. So you're returning a reference to invalid memory. If you're
not worried about copying Trees around, you can just remove the & from the
return type.
You might also want to assert( trees.size() > 0 ) to make sure the function
worked properly and there's something there to return.
That's the only actual problem I see. Otherwise I'm a little worried,
efficiency-wise, about how many vectors you're copying around, but that may
not be worth worrying about at this stage.
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|