CJCoding With Joseph
15free / daySign inCreate account

Seneca BTP 305

Debugging Class Memory Errors 2

Debugging Examples

The following code contains 4 logic errors and 2 syntax errors. Your task is to find and fix all of them, then make a post in the community explaining what you discovered and how you fixed it.

Hint: If you’re not sure where the errors are, copy the code below, compile it, and test different scenarios to see

ByteBox.h

#ifndef BYTEBOX_H
#define BYTEBOX_H

#include <iostream>

class ByteBox {
    std::size_t m_size;
    char* m_data;

public:
    ByteBox(std::size_t size = 0);
    ~ByteBox();

    ByteBox(const ByteBox& other) override;
    ByteBox(ByteBox&& other) noexcept override;

    char read(std::size_t idx) const;
    void write(std::size_t idx, char c);
};

#endif
Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 17 more lessons in Seneca BTP 305.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.