[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kuml-devel
Subject:    C++ simple question
From:       p_george <p_george () club-internet ! fr>
Date:       1999-11-30 21:36:13
[Download RAW message or body]

When implementing copy/paste function I encountered the following C++
problem :

I need to duplicate an object (DrawingItem), with the right constructor
being called.

When trying

       for (item = iter.toFirst();(item = iter.current()); ++iter) {
          diagram->addDrawingItem(new DrawingItem(item));
         	}

The compiler complains that DrawingItem has virtual functions that it
cannot find. This is normal. Is there a way to avoid the virtual copy
constructor ? (which should fix this).

An example of what is a copy constructor is the class A below, which has
a 'i' attribute :

A::A(const A& x) {
  i = x.i;
}

A A::operator = (const A& x) {
  if (this != &x) {
    this->i = x.i;
  }
  return *this;
}

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic