0
#include <iostream>
#include <cassert>
#include <cstdlib>
#include "sequence.h"
using namespace std;
sequence::sequence ()
{
current_index = 0;
used = 0;
}
sequence::size_type sequence::size() const
{
return used;
}
void sequence::start ()
{
current_index = 0;
}
sequence::value_type sequence::current() const
{
return data[current_index];
}
void sequence::advance ()
{
assert (is_item());
current_index++;
}
bool sequence::is_item() const
{
return current_index < used;
}
void sequence::insert (const value_type& entry)
{
assert(size() < CAPACITY);
for (int i = used; i > current_index; i--)
{
data[i] = data[i-1];
data[current_index] = entry;
used++;
}
}
void sequence::attach (const value_type& entry)
{
assert(size() < CAPACITY);
for (int i = used; i > current_index; i--)
{
data[i] = data[i+1];
data[current_index] = entry;
used++;
}
}
void sequence::remove_current()
{
assert (is_item());
for (int i = current_index+1; i < used-1; i++)
{
data[i] = data[i+1];
used--;
}
}
ostream& operator <<(ostream& outs, const sequence& source)
{
outs << source.current() << " ";
return outs;
}
Это специально, где у меня проблемы, и единственный код ошибки, который я получаю, - это тот, который указан в названии.Ошибка Valu_type не называет функцию C++
value_type operator[](size_type index)const
{
if(index > SIZE)
{
cout << "Index out of bounds" <<endl;
return sequence[0];
}
return sequence[i];
}
спасибо, но теперь он говорит мне, что size_type, что я везу в не объявлен в этой области. и ошибка: объявление 'operator []' как не-функции | –
То же, что и выше. 'sequence :: size_type' –
им жаль, что я не понимаю, можете ли вы разработать –