QT 4.8 在普通比较中崩溃
QT 4.8 crash at ordinary comparison
请帮我解释一下意外的崩溃!!我有:
X.H
class x: QObject
struct
{
struct
{
struct
{
int state;
double curstring;
QTimer timer_scroll;
QTimer timer_done;
}color;
struct
{
int state;
double curstring;
QTimer timer_scroll;
QTimer timer_done;
}mono;
}S2L_NOTIFY;
....等
x.cpp
void x::draw(const int type, QString str, bool isNeedAnswer)
{
if(type == 3)
{
//here is crash!
if(bitmap.S2L_NOTIFY.mono.state == 3 && bitmap.S2L_NOTIFY.color.state == 3)
{
if((bitmap.S2L_NOTIFY.mono.state == 3))
-<不会在这里崩溃>不会在这里崩溃>
if((bitmap.S2L_NOTIFY.color.state == 3))
-<不会在这里崩溃>不会在这里崩溃>
请告诉我哪里错了或编译器错了?
问题是你的条件中有x,但函数x::rndfunc()
是类x的成员函数......而不是变量。它应该是:
// "this" refers to the current instance of class x
if((this->y.z.f.nmb2 == NOTOK) && (this->y.z.f.nmb1 == NOTOK))
或者简单地:
// but the "this" isn't actually necessary
if((y.z.f.nmb2 == NOTOK) && (y.z.f.nmb1 == NOTOK))
(正如你所写)。
编辑:好的,所以原始问题中有一个错字,所以上面的内容不再相关。新的答案是:
f
没有成员变量nmb1
,只有nmb2
。
编辑#2:更多错别字。我的新答案:
你想做的事情看起来真的很混乱。别这样。
相关文章:
- 当回溯以零开始时,如何调试崩溃
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- 为什么比较运算符如此快速
- 我可以使用 g++ 进行三种比较 (<=>) 吗?
- 内联映射初始化的动态atexit析构函数崩溃
- 执行函数时导致崩溃的变量
- 程序崩溃并显示"std::out_of_range"错误
- 比较字符数组
- 将模板化的类型与C++中的某些类/类型进行比较
- C++自定义比较函数
- 比较迭代器会使程序崩溃,而不会在自定义气泡排序实现中出现错误
- 如果调用 RtlSetProcessIsCritical,将使用 lstrcmpW 将命令行与值进行比较将使程序崩溃
- 从数组比较2个字符串时,程序崩溃
- std::sort 以严格的弱排序崩溃 - 与垃圾值进行比较
- Vector::迭代器在与开始比较时崩溃
- 正在比较标头记录值和读取程序崩溃的行数.C++
- QT 4.8 在普通比较中崩溃
- 如果比较函数不是运算符<,为什么std::sort会崩溃;
- Lua函数在使用Luabind比较存储的C++对象指针时崩溃
- 奇怪的字符串比较崩溃