Whenever I try to run my code I get these error lines. It also seems like that sometimes it crashes the program. Is that possible or something else causes the crash? The error code comes to these lines:
Buffer<char*> s(20,"s.txt","rw"); //20 long char*
for(unsigned int i=0;i<24;i++){ //it overwrites the size of s after default 20
s[i]="hey"; //error here: "deprecated conversion from string constant to 'char*'"
The class looks like this(deleted the unimportant parts":
template<class T>
class Buffer:public File_ptr
{
unsigned int siz;
T *data;
public:
///constructor(size,filename,openmode)
Buffer(unsigned int s,const char* n, const char* m):File_ptr(n,m),siz(s)
{
data= new T[siz];
/* for(unsigned int i=0; i<siz; ++i)
{
data[i]=0;
}; */
};
///destructor
~Buffer()
{
delete[] data;
}
///operator[]
T& operator[](unsigned int i)
{
if(i>siz-1)
{
unsigned int newsize=siz*2;
T* tmp=new T[newsize];
for(unsigned int j = 0; j < siz; j++)
{
tmp[j] = data[j];
}
siz=newsize;
delete[] data;
data=tmp;
};
return data[i];
};
Any idea why I get the error? Thanks in advance!