KDE TechBase
  • Page
  • Discussion
  • Edit
  • +
  • History
KDE TechBase is a Wiki - You can help! Please contribute! Questions?
Please ask development related questions in the KDE Community Forum.

Talk:Policies/Library Code Policy/Shared D-Pointer Example

< Talk:Policies | Library Code Policy

Can someone please give an example how to implement the copy constructor correctly in the base and derived class? I spent some hours to find out how it could work and I'm doing it like this:

Base(const Base &other)
 : d_ptr(new BasePrivate(other.d_func()->property1,
other.d_func()->property2...)
{
}
 
Derived(const Derived &other)
 : Base(*new DerivedPrivate(other.d_func()->property1,
other.property2, other.d_func()->property3....))
{
}

It works but somehow it doesn't feel like it was meant that way.

Retrieved from "http://techbase.kde.org/Talk:Policies/Library_Code_Policy/Shared_D-Pointer_Example"

Navigation

  • Home
  • Help
  • Recent changes

Sections

  • Getting started
  • Development
  • Schedules
  • Policies
  • Contribute
  • Projects

Toolbox

  • What links here
  • Related changes
  • Special pages
  • Printable version
  • Permanent link

Personal tools

  • 38.107.191.96
  • Talk for this IP
  • Log in / create account
  • Login with OpenID
Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal