I'm just creating a simple list and then destroying it. And something is going wrong and I always get this annoying error message:
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
Here's the code:
#include<iostream>
#include<Windows.h>
using namespace std;
struct node
{
    int data;
    node *next;
};
class list
{
protected:
    node *top;
public:
    list()
    {
        top=NULL;
    }
    list random()
    {
        int x=rand()%10;
        for(int i=0; i<x; i++)
        {
            node *p=new node;
            p->data=rand()%100;
            p->next=top;
            top=p;
        }
        return *this;
    }
    void show()
    {
        for(node *p=top; p; p=p->next)
        {
            cout<<p->data<<" ";
        }
        cout<<"\n";
    }
    ~list()
    {
        node *r;
        for(node *p=top; p; p=r)
        {
            r=p->next;
            delete p;
        }
    }
};
int main()
{
    srand(GetTickCount());
    list a;
    a.random().show();
    return 0;
}
 
     
     
     
    