exercism / exercism/website-copy

"We received the following error when we ran your code:" but no error is following

Open
#2,199 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
217
Forks
944
PR merge metrics
No merged PRs in 30d

Description

I'm on the site: https://exercism.org/tracks/cpp/exercises/circular-buffer/edit

My .hh source code is:

```
#if !defined(CIRCULAR_BUFFER_H)
#define CIRCULAR_BUFFER_H
#include
#include
using namespace std;
namespace circular_buffer {
template
class circular_buffer
{

public:
int pos=0;
int writepos=0;
int len=0;
vector elems;
int num;
circular_buffer(int num): elems(num)
{
num=num;
}

T read()
{
if (len==0)
throw domain_error("alma");
len--;
T ret= elems[pos];
pos=(pos+1)%num;
return ret;

}

void write(T a)
{
if (len==num)
throw domain_error("alma");
len++;


writepos=(writepos+1)%num;
elems[writepos]=a;


}

void clear()
{
len=0;

}

void overwrite(T a)
{
if (len==num)
{}
else
len++;


writepos=(writepos+1)%num;
elems[writepos]=a;


}

};

} // namespace circular_buffer

#endif // CIRCULAR_BUFFER_H
```

The .cc source code is the default

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.