|
1Qter豆
请教 在 cpp 中返回该变量的地址 和 和直接在.h文件中返回变量地址不一样
在一个类display_sensor_info_Form中定义了个私有变量bool 类型
bool is_testing;
在构造函数中打印变量的地址
qDebug() << "is_testing :" << QString::number((int)&is_testing,16);
在mainwindow中调用
p_display_sensor_info_Form = new display_sensor_info_Form(p_parameter,this);
int dsif_addr = p_display_sensor_info_Form->return_addr(); qDebug() << QString::number(dsif_addr,16);
dsif_addr = p_display_sensor_info_Form->return_addr_fb(); qDebug() << QString::number(dsif_addr,16);
在 cpp 中返回该变量的地址 和 和直接在.h文件中返回变量地址不一样
int display_sensor_info_Form::return_addr_fb()
{
return (int)&is_testing;
}
和直接在.h文件中返回变量地址不一样
public:
explicit display_sensor_info_Form(
struct parameter_struct *p,
QWidget *parent = 0);
~display_sensor_info_Form();
void set_object_enable(bool state);
int return_addr_fb();
int return_addr()
{
return (int)&is_testing;
}
运行结果
第一个为构造函数
第二个为.h中直接返回
第3个是在cpp文件中单独一个返回函数
|
|