I am trying to wtite a programme for link list using class.I don't know the the error in deleting in the fuction del1 in the class linklist . Please check the error.
You have declared : linklist *ptr1,*ptr2,*ptr4,*ptr3,*ptr5;, but not ptr.
I'm suspecting you mean:
129 130
if(ptr1!=NULL)
{if(b==ptr1->taken())
As senhor mentioned, it is best to state your problem clearly and specifically, including any error messages you get from the compiler, linker or program crash. That helps us to help you better.
Please do let us know if you need any further help.
Please see this link for information specific to code::blocks:
http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks
With GDB, note that your program needs to be compiled with the "-g" flag, you could do:
#gdb (your program name)
gdb> run
[segfault]
gdb> bt
"bt" will show you a backtrace of where the program crashed. For more information about using GDB to track a segfault, please see: http://www.cplusplus.com/articles/iwTbqMoL/
To use debug output statements, do something like this, but in the whole program:
int main()
{
cout<<"first enter strings\n";
cout<<"enter \"end\" to stop entering strings\n";
std::cout << "--Creating linked list pointers\n";
linklist *f,*t,*s;
string m;
cin>>m;
std::cout << "--initializing f\n";
f=new linklist;
f->input(&m);
cin>>m;
if(m=="end")
{
std::cout << "--m==end, setting f->ptr=NULL\n";
f->ptr=NULL;
goto aa;
}
//...
Also, note that the use of "goto" is discouraged. Mostly for purposes like this, it gets really tough to debug a program that just jumps from one place to another with no seeming logic behind it.