Show: Object Pascal C++
Display Preferences

Access underrun

From Appmethod Topics
Jump to: navigation, search

Go Up to Access Errors


The Access Underrun error is similar in semantics with the Access Overrun error, except that the invalid memory access occurs before the region of memory, not after it.

#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[2];
  int answ;
  answ = myc[-1].publicalval = 10; // error
  delete[] myc;

}



int _tmain(int argc, _TCHAR* argv[])
{
	myf();
	return 0;
}
Personal tools
In other languages