Re: [Dev-C++] Glib::ustring::assign(...)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jamiil A. <jal...@gm...> - 2007-08-18 14:28:28
|
Sorry, for being so lazy and not post a more elaborate question, I hope this
would be a better way to ask this question.
jme::Combo::Combo(const Glib::ustring& title){
Glib::ustring* ustr;
std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown"));
if(!title.empty()) {
this->ustr->assign(title);
}
}
Thanks in advance!
----- Original Message -----
From: "Reid Thompson" <rei...@at...>
To: "Jamiil Abduqadir" <jal...@gm...>
Cc: "'Dev Cpp MailingLinst'" <dev...@li...>
Sent: Friday, August 17, 2007 5:33 PM
Subject: Re: [Dev-C++] Glib::ustring::assign(...)
> Jamiil Abduqadir wrote:
>> std::auto_ptr<Glib::ustring> ustr(new Glib::ustring("Unknown"));
>> if(!title.empty())
>> {
>> this->ustr->assign(title); // Segmentation Fault <<=====
>> }
>> Be my guest.
> what's the definition of ustr????
>
>
> does this example work on your system?
>
> http://wwwasd.web.cern.ch/wwwasd/lhc++/RW/stdlibcr/aut_3512.htm
>
> //
> // auto_ptr.cpp
> //
> #include <iostream.h>
> #include <memory>
> //
> // A simple structure.
> //
> struct X
> {
> X (int i = 0) : m_i(i) { }
> int get() const { return m_i; }
> int m_i;
> };
> int main ()
> {
> //
> // b will hold a pointer to an X.
> //
> auto_ptr<X> b(new X(12345));
> //
> // a will now be the owner of the underlying pointer.
> //
> auto_ptr<X> a = b;
> //
> // Output the value contained by the underlying pointer.
> //
> cout << a->get() << endl;
> //
> // The pointer will be deleted when a is destroyed on
> // leaving scope.
> //
> return 0;
> }
> Output :
> 12345
|