Don't use pointers to temporary objects. Either make those structures heap based or don't use pointers at all. I'm still curious what errors did you get while trying to use a reference... Maybe you forgot the magic "const" keyword? It is possible if you wanted to reference a temporary object.