I've got the following piece of code:
Class Chain
with
char* c;
as its only public atrib
istream& operator>>(istream& i, Chain& s) {
delete [] s.c;
const int L = 256;
char *t = new char[L];
i.getline(t,L);
s.c = t;
return i;
}
ostream& operator<<(ostream& o, Chain s) {
o << s.c;
return o;
}
#include
#include "Chain.h"
using namespace std;
int main(){
Chain id;
cin >> id;
cout << id;
cout << id;
After running the code under the Eclipse IDE on Xubuntu (last version) I get the following error:
Error in [...] double free or corruption (top): 0x00000000008fd290 ***
What could be wrong?
No comments:
Post a Comment