Re: Glib::ustring strange error msg ??



On Wed, 2008-05-07 at 22:09 -0400, Jamiil wrote:
> const Glib::ustring& jve::Person::getTitle(){
>    switch(title){
>       case Mr:   {return "Mr";  }
>       case Mrs:  {return "Mrs"; }
>       case Miss: {return "Miss";}
>       case Ms:   { return "Ms"; }
>       case Dr:   { return "Dr"; }
>       default:   {return "None";}
>    }
> }
>    
> Glib::ustring msg = person->getTitle(); <<=== this causes an 
> segmentation fault

You are returning a reference to a temporary. Your compiler should have
told you already with a warning.


Hub



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]