Reference to freed resource

From Appmethod Topics
Jump to: navigation, search

Go Up to CodeGuard Errors Index

The Reference To Freed Resource error occurs if you attempt to free a resource twice. There are several ways to create this error; the following code demonstrates one:

#include <tchar.h>
#pragma hdrstop
#include<stdio.h>
#include<dir.h>
class someclass{
	int fnumber;
  public:
	int getnumber(){return fnumber;}
	void setnumber(int nw){fnumber = nw;}
	int doublev(int val){return val*2;}
	int publicalval;

};

void myf()
{
  someclass *myc = new someclass[10];
  delete[] myc;
  delete[] myc;
	
}



int _tmain(int argc, _TCHAR* argv[])
{
	myf();
	return 0;
}