Re: Object copying
- From: Jonathon Jongsma <jonathon quotidian org>
- To: Glus Xof <gtglus gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Object copying
- Date: Fri, 10 Sep 2010 13:58:34 -0500
On Fri, 2010-09-10 at 19:50 +0200, Glus Xof wrote:
> 2010/9/10 Jonathon Jongsma <jonathon quotidian org>:
> > On Fri, 2010-09-10 at 19:02 +0200, Glus Xof wrote:
> >> Hi all,
> >>
> >> After trying to make the copy of an object, I get the following message:
> >>
> >> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >> In file included from ./groups.h:8,
> >> from groups.cc:1:
> >> /usr/local/include/gtkmm-2.4/gtkmm/treemodelcolumn.h: In member
> >> function ‘User::KeyModelColumns&
> >> User::KeyModelColumns::operator=(const User::KeyModelColumns&)’:
> >> /usr/local/include/gtkmm-2.4/gtkmm/treemodelcolumn.h:92: error:
> >> ‘Gtk::TreeModelColumnRecord&
> >> Gtk::TreeModelColumnRecord::operator=(const
> >> Gtk::TreeModelColumnRecord&)’ is private
> >> ././user.h:148: error: within this context
> >> ././user.h: In member function ‘User& User::operator=(const User&)’:
> >> ././user.h:16: note: synthesized method ‘User::KeyModelColumns&
> >> User::KeyModelColumns::operator=(const User::KeyModelColumns&)’ first
> >> required here
> >> /usr/local/include/gtkmm-2.4/gtkmm/comboboxtext.h:49: error:
> >> ‘Gtk::ComboBoxText& Gtk::ComboBoxText::operator=(const
> >> Gtk::ComboBoxText&)’ is private
> >> ././user.h:16: error: within this context
> >> /usr/local/include/gtkmm-2.4/gtkmm/comboboxtext.h:49: error:
> >> ‘Gtk::ComboBoxText& Gtk::ComboBoxText::operator=(const
> >> Gtk::ComboBoxText&)’ is private
> >> ././user.h:16: error: within this context
> >> /usr/local/include/gtkmm-2.4/gtkmm/entry.h:122: error: ‘Gtk::Entry&
> >> Gtk::Entry::operator=(const Gtk::Entry&)’ is private
> >> ././user.h:16: error: within this context
> >> /usr/local/include/gtkmm-2.4/gtkmm/button.h:80: error: ‘Gtk::Button&
> >> Gtk::Button::operator=(const Gtk::Button&)’ is private
> >> ././user.h:16: error: within this context
> >> /usr/local/include/gtkmm-2.4/gtkmm/treeview.h:199: error:
> >> ‘Gtk::TreeView& Gtk::TreeView::operator=(const Gtk::TreeView&)’ is
> >> private
> >> ././user.h:16: error: within this context
> >> /usr/local/include/gtkmm-2.4/gtkmm/table.h:193: error: ‘Gtk::Table&
> >> Gtk::Table::operator=(const Gtk::Table&)’ is private
> >> ././user.h:16: error: within this context
> >> /usr/local/include/gtkmm-2.4/gtkmm/menu.h:77: error: ‘Gtk::Menu&
> >> Gtk::Menu::operator=(const Gtk::Menu&)’ is private
> >> ././user.h:16: error: within this context
> >> groups.cc: In member function ‘void Groups::set_user_object(const User&)’:
> >> groups.cc:113: note: synthesized method ‘User& User::operator=(const
> >> User&)’ first required here
> >> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >>
> >> What's happen ???
> >
> > The object is not copyable. you'll need to pass it by reference
> > (pointer, reference) rather than by value.
>
> In a certain manner, it's what I do. I try to pass the object by
> reference to a new one, and once inside, trying copying to make it
> visible for all class methods...
>
> --------------
> class Groups
> {
> public:
> void set_user_object (const User &);
> [...]
> private:
> User user;
> [...]
> };
>
> void Groups::set_user_object (const User & myuser)
> {
> user = myuser;
This is creating a copy. As I said, the object is not copyable. So you
cannot do that. You need to store a reference to the object instead.
jonner
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]