Thanks for your response.
I had an object allocated with new inside the function (FData *pData =
new...) , and i returned its contents (return *pData) but this gave me all
kind of problems when i put the returned object in a STL vector container,
so in fact I changed my declaration to be
FData &ParseFileTags(FData &Ret,char *path)
If all goes well, Ret contains good data after this call and i return that
same object. If not, I dont want to return a reference to that object, but
to another "NULL" object instead, or something that allows me to write
result = ParseFileTags(Ret,path);
if (result == NULL)
....
else
.....
I would prefer not to use exceptions, but as i write this i realize it may
be the only true solution...
"Attila Feher" <> escribió en el mensaje
news:bkp207$88i$...
> Pablo J Royo wrote:
> > Hello:
> >
> > i have a function that reads a file as an argument and returns a
> > reference to an object that contains some information obtained from
> > the file: FData &ReadFile(string FilePath);
> >
> > But , for example, when the file doesnt exists, i should not return
> > any reference to a bad constructed object, so i need something as a
> > NULL reference object. I suppose i could return a pointer instead,
> > but i have some code written with references which IŽd like to
> > preserve...
>
> You can throw an exception.
>
> BTW how do you return that reference? What does it refer to? I hope not
an
> automatic variable.
>
> > żHow can i do that?
>
> No need for that upside down question mark. 
>
> --
> Attila aka WW
>
>