当前位置:编程学习 > wap >>

菜鸟问题

两个自定义类,都是继承于QDialog,在一个类中创建另一个类的子对象就出错,怎么回事呀
class reg : public QDialog
{
   ...
  log *p;
}
class log : public QDialog
{
}
reg::reg ()
{
 p = new log;//加上这个就报错,注释掉就没事
}
--------------------编程问答--------------------
出错提示如下:

D:\QtTest\Qmeme-build-desktop\debug\Qmeme.exe 启动中...
Error - 
RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly

D:\QtTest\Qmeme-build-desktop\debug\Qmeme.exe 退出, 代码: -1073741819  --------------------编程问答-------------------- 最好能把代码多贴点,应该是别的地方有错 --------------------编程问答-------------------- “class reg : public QDialog”前面加上:class log;声明试试 --------------------编程问答-------------------- 楼主,以你现在贴的代码,我只能猜测,你是不是把声明和定义放一起了啊? 是不是写成一个大的文件了? --------------------编程问答-------------------- 觉得应该是  reg类的cpp缺少 log头文件的引用 --------------------编程问答--------------------
引用 4 楼  的回复:
楼主,以你现在贴的代码,我只能猜测,你是不是把声明和定义放一起了啊? 是不是写成一个大的文件了?

跟着打酱油.... --------------------编程问答-------------------- 应该是其他地方的错误 --------------------编程问答-------------------- //reg.h
#include "log.h"
class reg : public QDialog
{
  ...
  log *p;
};
//log.h
class log : public QDialog
{
};
reg::reg ()
{
 p = new log;//加上这个就报错,注释掉就没事
}

如果是这样的三个文件,应该没问题。或者把二个.h放在一起也可以。 --------------------编程问答--------------------
log *p=new log();
--------------------编程问答-------------------- //log.h
class log : public QDialog
{
};
这里不会真是空的吧?

调试吧,在构造函数里增加断点,单步运行,就知道哪里出错了。
还有可能是log内部的代码出错。 --------------------编程问答-------------------- 同楼上,我怀疑他真的写了一个空的log。
就连构造函数都没有。 - - --------------------编程问答--------------------
补充:移动开发 ,  Qt
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,