CJCoding With Joseph
15free / daySign inCreate account

Seneca BTP 305

Debugging Class Memory Errors 1

Debugging Examples

The following code contains 4 logic 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

TinyBuf.h

#ifndef TINYBUF_H
#define TINYBUF_H

#include <iostream>

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

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

    TinyBuf(const TinyBuf& other);
    TinyBuf(TinyBuf&& other) noexcept;

    char get(std::size_t idx) const;
    void set(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.