Let’s review some code: C++ #2

📰 Dev.to · pikoTutorial

Learn to review and improve C++ code by identifying mistakes and applying best practices

intermediate Published 20 May 2025
Action Steps
  1. Read the provided C++ code and try to identify mistakes before scrolling down to the solution
  2. Analyze the code for potential memory leaks, incorrect usage of pointers, and other common C++ pitfalls
  3. Apply best practices for C++ coding, such as using smart pointers and following the Rule of Five
  4. Use a debugger or online compiler to test and validate the corrected code
  5. Refactor the code to improve readability, maintainability, and performance
Who Needs to Know This

Software engineers and developers can benefit from this lesson to improve their coding skills and collaborate on code reviews

Key Insight

💡 Code review and refactoring are essential skills for software engineers to ensure high-quality, maintainable, and efficient code

Share This
Improve your C++ skills by learning to review and refactor code #cpp #programming #softwaredevelopment

Full Article

Title: Let’s review some code: C++ #2

URL Source: https://dev.to/pikotutorial/lets-review-some-code-c-2-39ad

Published Time: 2025-05-20T08:17:00Z

Markdown Content:
[Skip to content](https://dev.to/pikotutorial/lets-review-some-code-c-2-39ad#main-content)

[![Image 1: DEV Community](https://media2.dev.to/dynamic/image/quality=100/https://dev-to-uploads.s3.amazonaws.com/uploads/logos/resized_logo_UQww2soKuUsjaOGNB38o.png)](https://dev.to/)

[Powered by Algolia](https://www.algolia.com/developers/?utm_source=devto&utm_medium=referral)

[Log in](https://dev.to/enter?signup_subforem=1)[Create account](https://dev.to/enter?signup_subforem=1&state=new-user)

## DEV Community

![Image 2](https://assets.dev.to/assets/heart-plus-active-9ea3b22f2bc311281db911d416166c5f430636e76b15cd5df6b3b841d830eefa.svg)0 Add reaction

![Image 3](https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg)0 Like ![Image 4](https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg)0 Unicorn ![Image 5](https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg)0 Exploding Head ![Image 6](https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg)0 Raised Hands ![Image 7](https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg)0 Fire

0 Jump to Comments 0 Save Boost

Copy link

Copied to Clipboard

[Share to X](https://twitter.com/intent/tweet?text=%22Let%E2%80%99s%20review%20some%20code%3A%20C%2B%2B%20%232%22%20by%20piko%3A%3Atutorial%20%23DEVCommunity%20https%3A%2F%2Fdev.to%2Fpikotutorial%2Flets-review-some-code-c-2-39ad)[Share to LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fdev.to%2Fpikotutorial%2Flets-review-some-code-c-2-39ad&title=Let%E2%80%99s%20review%20some%20code%3A%20C%2B%2B%20%232&summary=Welcome%20to%20the%20next%20pikoTutorial%20%21%20%20Below%20you%20can%20find%20the%20code%20that%20we%20will%20be%20reviewing%20today....&source=DEV%20Community)[Share to Facebook](https://www.facebook.com/sharer.php?u=https%3A%2F%2Fdev.to%2Fpikotutorial%2Flets-review-some-code-c-2-39ad)[Share to Mastodon](https://s2f.kytta.dev/?text=https%3A%2F%2Fdev.to%2Fpikotutorial%2Flets-review-some-code-c-2-39ad)

[Share Post via...](https://dev.to/pikotutorial/lets-review-some-code-c-2-39ad#)[Report Abuse](https://dev.to/report-abuse)

[![Image 8: Cover image for Let’s review some code: C++ #2](https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx38wncropnvmnxl57t6.png)](https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx38wncropnvmnxl57t6.png)

[![Image 9: piko::tutorial](https://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2571313%2F656f33bf-95f2-4b7a-be58-2ec2542c49af.png)](https://dev.to/pikotutorial)

[piko::tutorial](https://dev.to/pikotutorial)
Posted on May 20, 2025 • Edited on May 16 • Originally published at [pikotutorial.com](https://pikotutorial.com/lets-review-some-code-c-2/)

# Let’s review some code: C++ #2

[#cpp](https://dev.to/t/cpp)[#programming](https://dev.to/t/programming)[#softwaredevelopment](https://dev.to/t/softwaredevelopment)[#softwareengineering](https://dev.to/t/softwareengineering)

Welcome to the next [pikoTutorial](https://pikotutorial.com/) !

Below you can find the code that we will be reviewing today. Before you scroll down to section where I fix it, feel free to check how many mistakes you can find.

```
#include <iostream>

class Logger
{
public:
~Logger()
{
std::cout << "Logger d
Read full article → ← Back to Reads