C ++ 0x00000000处的未处理异常 [英] C++ Unhandled exception at 0x00000000

查看:92
本文介绍了C ++ 0x00000000处的未处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我正在试图找出这个未处理的异常的来源

(坏指针或未分配的内存)


我有一个父类, IOField具有以下指向函数的指针


bool(* isValid)(void * data,IOScreen * scrPtr);


它保存地址一个函数被设计为在编辑后验证IOField的

数据。 IOField显示在

IOSCreen中,由scrPtr指示。


现在稍后在子类中,我想要调用函数

isValid;


if(isValid(data,this-> owner)== false)condition = true;


以前的函数为数据分配内存并在其中存储字符串,

和this->所有者在构造函数中设置。


数据和,this->所有者有一个地址,但isValid没有。


编译时,唯一的0x00000000地址是isValid;


Visual Studio 2005报道,

数据0x00129ac8无效*

+所有者0x0012920c {fnum = 15 row = 2 col = 5 ...}

IOScreen *

isValid 0x00000000 bool(void *,IOScreen *)*

+ this 0x00356b48 {flen = 20 slen = 40 curpos = 0 ...}

IOLineEdit * const


也许我在指向函数时做错了,我d我有很多使用它们的经验(他们在这所大学里需要这些学生

)。


感谢任何帮助并提前感谢。

Hello, I am trying to figure out the source of this unhandled exception
(bad pointer or unallocated memory)

I have a parent class, IOField with the following pointer to function

bool (*isValid)(void *data, IOScreen *scrPtr);

This holds the address of a function that is desinged to validate the
data of an IOField after being edited. The IOField is displayed in an
IOSCreen pointed by "scrPtr".

Now later on in a child class, I want to make a function call to
isValid;

if(isValid(data,this->owner) == false) condition = true;

Previous functions allocate memory for data and store strings in them,
and this->owner is set in the constructor.

data and, this->owner has an address but isValid does not.

When compiling, the only address with 0x00000000 is isValid;

Visual Studio 2005 reports,
data 0x00129ac8 void *
+ owner 0x0012920c {fnum=15 row=2 col=5 ...}
IOScreen *
isValid 0x00000000 bool (void *, IOScreen *)*
+ this 0x00356b48 {flen=20 slen=40 curpos=0 ...}
IOLineEdit * const

Maybe I am doing something wrong with pointer to functions, I dont have
*that* much experience using them (they are required in this college
assignment).

Appreciate any help and thanks in advance.

推荐答案

AMT2K5写道:
你好,我想弄明白这个未处理的异常的来源
(坏指针或未分配的内存)

我有一个父类,IOField带有以下指针功能

bool(* isValid) (void * data,IOScreen * scrPtr);

它保存了一个函数的地址,该函数被设计为在编辑后验证IOField的数据。 IOField显示在由scrPtr指向的IOSCreen中。

现在稍后在子类中,我想对函数进行调用
isValid;

if(isValid(data,this-> owner)== false)condition = true;

以前的函数为数据分配内存并在其中存储字符串,
并且这个>所有者是在构造函数中设置的。

数据,这个 - >所有者有一个地址但isValid没有。

编译时,唯一的地址与0x00000000是isValid;

Visual Studio 2005报告,数据0x00129ac8 void *
+所有者0x0012920c {fnum = 15 row = 2 col = 5 ...}
IOScreen *
isValid 0x00000000 bool(void *,IOScreen *)*
+这个0x00356b48 {flen = 20 slen = 40 curpos = 0 ...}
IOLineEdit * const

也许我在指向函数时做错了什么,我没有*使用它们的很多经验(他们这个大学需要分配。

提前感谢任何帮助和感谢。
Hello, I am trying to figure out the source of this unhandled exception
(bad pointer or unallocated memory)

I have a parent class, IOField with the following pointer to function

bool (*isValid)(void *data, IOScreen *scrPtr);

This holds the address of a function that is desinged to validate the
data of an IOField after being edited. The IOField is displayed in an
IOSCreen pointed by "scrPtr".

Now later on in a child class, I want to make a function call to
isValid;

if(isValid(data,this->owner) == false) condition = true;

Previous functions allocate memory for data and store strings in them,
and this->owner is set in the constructor.

data and, this->owner has an address but isValid does not.

When compiling, the only address with 0x00000000 is isValid;

Visual Studio 2005 reports,
data 0x00129ac8 void *
+ owner 0x0012920c {fnum=15 row=2 col=5 ...}
IOScreen *
isValid 0x00000000 bool (void *, IOScreen *)*
+ this 0x00356b48 {flen=20 slen=40 curpos=0 ...}
IOLineEdit * const

Maybe I am doing something wrong with pointer to functions, I dont have
*that* much experience using them (they are required in this college
assignment).

Appreciate any help and thanks in advance.



你是否已初始化/为`isValid赋值''? (看起来好像是

你还没有。)


向我们展示你班级的施工人员,我们也许可以提供帮助。


HTH,

-ag

-

Artie Gold - 奥斯汀,德克萨斯州
http://goldsays.blogspot.com (新帖子8/5 )
http://www.cafepress.com/goldsays

"如果你没有什么可隐藏的,你就没有尝试!


Have you initialized/assigned a value to `isValid''? (It sure looks like
you haven''t.)

Show us the constructors for your class and we might be able to help.

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you''re not trying!"


IOField :: IOField(int row,int col, void(* help)(IOScreen *),bool

(* isValid)(void *,IOScreen *)):Ok(true){

this-> row =行;

this-> col = col;

this-> help = help;

this-> isValid = isValid ;

this-> data = NULL;

setOwner(NULL);

}


IOLineEdit :: IOLineEdit(int row,int col,int flen,int slen,int * ins,

void(* help)(IOScreen *),bool(* isValid)(void *,IOScreen *)

):IOField(row,col,help, isValid){

Ok = false;

data = new char [slen + 1];

if(data){

Ok = true;

dynamic = true;

curpos = spos = 0;

this-> flen = flen;

this-> slen = slen;

this-> ins = ins;

((char *)data)[0] = 0;

}

}

IOField::IOField(int row, int col,void (*help)(IOScreen *), bool
(*isValid)(void *, IOScreen *)):Ok(true){
this->row = row;
this->col = col;
this->help = help;
this->isValid = isValid;
this->data = NULL;
setOwner(NULL);
}

IOLine:IOLineEdit(int row, int col, int flen, int slen, int *ins,
void (*help)(IOScreen *), bool (*isValid)(void *, IOScreen *)
):IOField(row,col,help,isValid){
Ok = false;
data = new char[slen+1];
if(data){
Ok = true;
dynamic = true;
curpos = spos = 0;
this->flen = flen;
this->slen = slen;
this->ins = ins;
((char*)data)[0] = 0;
}
}


AMT2K5写道:
您好,我正在试图弄清楚这个未处理的异常的来源
(坏指针或未分配的内存)

我有一个父类,IOField具有以下指向函数的指针
bool(* isValid)(void * data,IOScreen * scrPtr);

它包含一个函数的地址,该函数被设计为在验证IOField的数据之后正在编辑。 IOField显示在由scrPtr指向的IOSCreen中。

现在稍后在子类中,我想对函数进行调用
isValid;

if(isValid(data,this-> owner)== false)condition = true;

以前的函数为数据分配内存并在其中存储字符串,
并且这个>所有者是在构造函数中设置的。

数据,这个 - >所有者有一个地址但isValid没有。

编译时,唯一的地址与0x00000000是isValid;

Visual Studio 2005报告,数据0x00129ac8 void *
+所有者0x0012920c {fnum = 15 row = 2 col = 5 ...}
IOScreen *
isValid 0x00000000 bool(void *,IOScreen *)*
+这个0x00356b48 {flen = 20 slen = 40 curpos = 0 ...}
IOLineEdit * const

也许我在指向函数时做错了什么,我没有*使用它们的很多经验(他们这个学院需要分配。

提前感谢任何帮助和感谢。
Hello, I am trying to figure out the source of this unhandled exception
(bad pointer or unallocated memory)

I have a parent class, IOField with the following pointer to function

bool (*isValid)(void *data, IOScreen *scrPtr);

This holds the address of a function that is desinged to validate the
data of an IOField after being edited. The IOField is displayed in an
IOSCreen pointed by "scrPtr".

Now later on in a child class, I want to make a function call to
isValid;

if(isValid(data,this->owner) == false) condition = true;

Previous functions allocate memory for data and store strings in them,
and this->owner is set in the constructor.

data and, this->owner has an address but isValid does not.

When compiling, the only address with 0x00000000 is isValid;

Visual Studio 2005 reports,
data 0x00129ac8 void *
+ owner 0x0012920c {fnum=15 row=2 col=5 ...}
IOScreen *
isValid 0x00000000 bool (void *, IOScreen *)*
+ this 0x00356b48 {flen=20 slen=40 curpos=0 ...}
IOLineEdit * const

Maybe I am doing something wrong with pointer to functions, I dont have
*that* much experience using them (they are required in this college
assignment).

Appreciate any help and thanks in advance.




这个描述中无处可去你说你在哪里为isValid分配一个

地址。还可以通过调试器输出来判断isValid是否具有NULL的
地址。您是否有可能忘记分配地址

isValid?


如果这没有帮助,那么从您的程序中删除所有无关的代码,

所以你有一个小但仍然可编译的程序仍然有这个问题,然后在这里发布整个代码。如果没有看到代码就很难解决

编码问题。


john



Well nowhere in this descrption have you said where you assign an
address to isValid. Also judging by your debugger output isValid has an
address of NULL. Is it possible you just forgot to assign an address to
isValid?

If this doesn''t help then remove all extraneous code from your program,
so that you have a small but still compilable program which still has
this problem, then post the entire code here. It''s difficult to solve
coding problems without seeing the code.

john


这篇关于C ++ 0x00000000处的未处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆