<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Uzair Ahmad</title>
    <description>The latest articles on DEV Community by Uzair Ahmad (@uzairahmad8).</description>
    <link>https://dev.to/uzairahmad8</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1035148%2Fb97e7fdc-6c14-4e6c-901a-3bd94a155bf2.jpg</url>
      <title>DEV Community: Uzair Ahmad</title>
      <link>https://dev.to/uzairahmad8</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uzairahmad8"/>
    <language>en</language>
    <item>
      <title>To Copy or Not to Copy: Understanding Shallow and Deep Copying in Code</title>
      <dc:creator>Uzair Ahmad</dc:creator>
      <pubDate>Mon, 17 Apr 2023 01:00:54 +0000</pubDate>
      <link>https://dev.to/uzairahmad8/to-copy-or-not-to-copy-understanding-shallow-and-deep-copying-in-code-1929</link>
      <guid>https://dev.to/uzairahmad8/to-copy-or-not-to-copy-understanding-shallow-and-deep-copying-in-code-1929</guid>
      <description>&lt;p&gt;Shallow Copy:-&lt;/p&gt;

&lt;p&gt;A shallow copy in C++ is a copy that creates a new object and copies the member variables' addresses of the original object to the new object.&lt;/p&gt;

&lt;p&gt;However, the memory locations pointed to by the pointers in the new object are not copied, but rather their addresses are simply copied. This means that both the original object and the new object will point to the same memory locations, which can lead to unintended consequences if changes are made to the shared data.&lt;/p&gt;

&lt;p&gt;A shallow copy can be made by simply copying the reference.&lt;/p&gt;

&lt;p&gt;Example:-&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3hyJdqq---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ixd08js48dhiwrzuixpw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3hyJdqq---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ixd08js48dhiwrzuixpw.png" alt="Image description" width="550" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Deep Copy:-&lt;/p&gt;

&lt;p&gt;A deep copy in C++ is a copy that creates a new object and copies all member variables of the original object to a new object, including copying the memory pointed to by the pointers to new memory locations.&lt;/p&gt;

&lt;p&gt;A deep copy means creating a new array and copying over the values. Changes to the array values referred to will not result in changes to the array data refers to.&lt;/p&gt;

&lt;p&gt;Example:-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3rQfrzOO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjge1ws30cvca4j24lxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3rQfrzOO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjge1ws30cvca4j24lxt.png" alt="Image description" width="784" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;it's good programming practice to use a deep copy when you need to create a new object that is independent of the original object and does not share any data with it.&lt;/p&gt;

&lt;p&gt;On the other hand, shallow copying is useful when you want to create a new object that shares data with the original object.&lt;/p&gt;

&lt;p&gt;In general, if you need a new object that is independent of the original object, a deep copy is recommended, while if you need a new object that shares data with the original object, a shallow copy may be applicable.&lt;/p&gt;

&lt;p&gt;Don't forget to follow for more amazing programming content.&lt;/p&gt;

</description>
      <category>objectorientedprogrammin</category>
      <category>cpp</category>
      <category>programming</category>
      <category>coding</category>
    </item>
    <item>
      <title>Amazing fact about learning things..</title>
      <dc:creator>Uzair Ahmad</dc:creator>
      <pubDate>Thu, 02 Mar 2023 20:38:12 +0000</pubDate>
      <link>https://dev.to/uzairahmad8/amazing-fact-about-learning-things-2g1c</link>
      <guid>https://dev.to/uzairahmad8/amazing-fact-about-learning-things-2g1c</guid>
      <description>&lt;p&gt;We Learn 10% of what we READ.&lt;/p&gt;

&lt;p&gt;We Learn 20% of what we HEAR.&lt;/p&gt;

&lt;p&gt;We Learn 30% of what we SEE.&lt;/p&gt;

&lt;p&gt;We Learn 50% of what we SEE &amp;amp; HEAR.&lt;/p&gt;

&lt;p&gt;We Learn 70% of what we DISCUSS.&lt;/p&gt;

&lt;p&gt;We Learn 80% of what we EXPERIENCE.&lt;/p&gt;

&lt;p&gt;We Learn 95% of what we TEACH to others.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>beginners</category>
      <category>knowledge</category>
    </item>
  </channel>
</rss>
