Jan 23, 2010 at 5:13pm UTC
when I run this code I get an error array::operator[] must return a value
now do I have to use a pointer to declare an array or just
declare array[8] in my array::array(void) once again I am newbie thanks
#include "Array.h"
#include <stdexcept>
Array::Array (void)
{
}
Array::Array (size_t length)
{
}
Array::Array (size_t length, char fill)
{
}
Array::Array (const Array & array)
{
}
Array::~Array (void)
{
}
const Array & Array::operator = (const Array & rhs)
{
return *this;
}
char & Array::operator [] (size_t index)
{
//return *this;
}
const char & Array::operator [] (size_t index) const
{
}
char Array::get (size_t index) const
{
return 0;
}
void Array::set (size_t index, char value)
{
}
void Array::resize (size_t new_size)
{
}
int Array::find (char ch) const
{
return 0;
}
int Array::find (char ch, size_t start) const
{
return 0;
}
bool Array::operator == (const Array & rhs) const
{
return true;
}
bool Array::operator != (const Array & rhs) const
{
return true;
}
void Array::fill (char ch)
{
}
Jan 23, 2010 at 6:38pm UTC
And don't forget code tags.
Jan 23, 2010 at 7:03pm UTC
this is my array.h
class Array
{
public:
Array (void);
Array (size_t length);
Array (size_t length, char fill);
~Array (void);
const Array & operator = (const Array & rhs);
size_t size (void) const;
size_t max_size (void) const;
char & operator [] (size_t index);
const char & operator [] (size_t index) const;
char get (size_t index) const;
void set (size_t index, char value);
void resize (size_t new_size);
int find (char ch) const;
int find (char ch, size_t start) const;
bool operator == (const Array & rhs) const;
bool operator != (const Array & rhs) const;
void fill (char ch);
private:
char * data_;
size_t cur_size_;
size_t max_size_;
};
#endif // !defined _ARRAY_H_
Jan 23, 2010 at 8:43pm UTC
Hi Moorecm thanks this is exactly what I needed. I have grab the concept now I will keep you posted on my results