Resource type mismatch

From Appmethod Topics
Jump to: navigation, search

Go Up to CodeGuard Errors Index

The Resource Type Mismatch error is caused by freeing a resource in a manner that is inconsistent with the way the resource was allocated.

#include <tchar.h>
#pragma hdrstop
#include<stdio.h>
#include<dir.h>
#include <tchar.h>
#pragma hdrstop
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();
	delete[] myc; // error
	someclass* myk = new someclass[2];
	delete myk; //error
}

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